Wednesday, June 8, 2011

Displaying Custom HTML Content Using cl_gui_html_viewer


  Here is my sample program that contains necessary operations to display custom html content using cl_gui_html_viewer. It is simple and would be very useful in some cases.


*&---------------------------------------------------------------------*
*& Report  ZZTEST
*&---------------------------------------------------------------------*
REPORT  zztest .

*** cl_gui_html_viewer instance
DATA : gr_browser TYPE REF TO cl_gui_html_viewer.

*** Data definitions HTML Content
DATA : gv_url(1024)  TYPE c.
DATA : gt_html TYPE TABLE OF char255 WITH HEADER LINE.
DATA : gs_html LIKE LINE OF gt_html.
DATA : gv_color TYPE string VALUE '#e5f1f4'.

*** Internal Table That has main Data
DATA : BEGIN OF gt_main OCCURS 10,
       persno TYPE i,
       name TYPE string,
       age TYPE i,
       END OF gt_main.

*** Macro helps to create HTML content table
DEFINE add_to_html.
  clear : gs_html.
  gs_html = &1.
  append gs_html to gt_html.
END-OF-DEFINITION.

*** START-OF-SELECTION
START-OF-SELECTION.

  PERFORM add_data_for_demo.

  CALL SCREEN 100.


*&---------------------------------------------------------------------*
*&      Form  add_data_for_demo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM add_data_for_demo.

*** Demo table to show
  DATA : lv_temp TYPE string.

  DO 30 TIMES.
    lv_temp = sy-index.
    CONCATENATE 'Employee No ' lv_temp INTO lv_temp SEPARATED BY ' '.

    CLEAR : gt_main.
    gt_main-persno = sy-index + 60 .
    gt_main-name = lv_temp.
    gt_main-age = ( sy-index + 60 ) / 3.
    APPEND gt_main.
  ENDDO.

ENDFORM.                    "add_data_for_demo
*&---------------------------------------------------------------------*
*&      Module  pbo_100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo_100 OUTPUT.

  SET PF-STATUS 'PFST100'.
  SET TITLEBAR 'TITLE100'.

*** Show Html Table
  PERFORM html_viewer.

ENDMODULE.                 " pbo_100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  pai_100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai_100 INPUT.

  CASE sy-ucomm.

    WHEN 'BACK'.
      LEAVE PROGRAM.

  ENDCASE.

ENDMODULE.                 " pai_100  INPUT

*&---------------------------------------------------------------------*
*&      Form  html_viewer
*&---------------------------------------------------------------------*
FORM html_viewer .

*** Create Instance Using Default Screen As Parent
  CREATE OBJECT gr_browser
    EXPORTING
      parent = cl_gui_container=>screen0.


*** Create Your HTML Content
  gv_url = 'test.htm'.

*** Html Head
  add_to_html :
  '<html><head><meta http-equiv=Content-Type content="text/html; ',
  'charset=UTF-8"></head><body style="background:#b8fa84">' .

*** Html Body
*** Html Body
  add_to_html : '<b> THANKS to cl_gui_html_viewer </b><br><br><br>'.


*** Html Table Properties : You can also use css
  add_to_html :
    '<table border=1 cellpadding=1 cellspacing=0',
    'width=''500px''><thead>',
    '<tr style="background:lightgray;text-align:center;">',
    '<td colspan=3>',
    '<b > Report Header </b>',
    '</td></tr></thead>'.

*** Add header to html table
  add_to_html :
   '<tr align=center><td style="width:20%;background-color:azure">ID',
   '</td><td style="width:40%;background-color:azure">Name',
 '</td><td style="width:40%;background-color:azure;">Age</td></tr>'.


*** Show your internal table
  LOOP AT gt_main.
    PERFORM add_lines USING
          gt_main-persno gt_main-name gt_main-age.
  ENDLOOP.


*** Close HTML
  add_to_html : '</table></body></html>'.

*** Load HTML Data
  CALL METHOD gr_browser->load_data
    EXPORTING
      url          = gv_url
    IMPORTING
      assigned_url = gv_url
    CHANGING
      data_table   = gt_html[].

*** Show Url
  CALL METHOD gr_browser->show_url
    EXPORTING
      url = gv_url.

  CALL METHOD cl_gui_html_viewer=>set_focus
    EXPORTING
      control           = gr_browser
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_error = 2
      OTHERS            = 3.



ENDFORM.                    " html_viewer
*&---------------------------------------------------------------------*
*&      Form  add_lines
*&---------------------------------------------------------------------*
FORM add_lines USING p_1 p_2 p_3.

  DATA : lv_str1 TYPE string.
  DATA : lv_str2 TYPE string.
  DATA : lv_str3 TYPE string.

*** Zebra Style
  IF gv_color = '#e5f1f4'.
    gv_color = '#f8fbfc'.
  ELSE.
    gv_color = '#e5f1f4'.
  ENDIF.

  lv_str1 = p_1.
  lv_str2 = p_2.
  lv_str3 = p_3.

  CONCATENATE
  '<tr align=center><td style="width:20%;background-color:'
  gv_color '">' lv_str1 '</td>' INTO gs_html.
  APPEND gs_html TO gt_html.

  CONCATENATE
  '<td style="width:40%;background-color:' gv_color '">' lv_str2
  '</td><td style="width:40%;background-color:'
  gv_color '">' lv_str3  '</td></tr>'
  INTO gs_html.
  APPEND gs_html TO gt_html.

ENDFORM.                    "add_lines

Tuesday, May 17, 2011

USING ALV EVENT HANDLER FOR ALL INSTANCES

 We have more than one alv grid instance ( cl_gui_alv_grid ). Instead of defining separate event handlers for each instance , we could define one for an event using  FOR ALL INSTANCES keyword.

 When any of them fires related event, we could catch and take actions. But how do we know the instance ? Sender parameter is the key.

*** INSTANCES
    DATA go_alv01 TYPE REF TO cl_gui_alv_grid ,
           go_alv02 TYPE REF TO cl_gui_alv_grid ,
           go_alv03 TYPE REF TO cl_gui_alv_grid .
 
*** LINK EVENTS TO INSTANCE
SET HANDLER go_event_handler->handle_double_click FOR ALL INSTANCES.

*** DEFINITION OF EVENT
*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
class lcl_event_handler definition .

  public section .

    class-methods:

     handle_double_click
     for event double_click of cl_gui_alv_grid
     importing e_row e_column sender.

  private  section.

endclass.                    "lcl_event_handler DEFINITION


*** IMPLEMENTATION OF EVENTS
*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
class lcl_event_handler implementation .


  method handle_hotspot_click.


   CASE sender.
   
     WHEN go_alv01.
     " go_alv01 has fired the event
   
     WHEN go_alv02.
     " go_alv02 has fired the event
    
     WHEN go_alv03.
     " go_alv03 has fired the event
    
   ENDCASE.



  endmethod.                    "handle_hospot_click

   

Friday, April 22, 2011

Gos Manager Class cl_gos_manager

 cl_gos_manager is very useful to manage attachments on a report. It lets you upload and download files related any object inside your report. You can also take notes. Simple to use ;

  DATA go_manager   TYPE REF TO cl_gos_manager,
         lp_no_commit TYPE        sgs_cmode,
         gp_service   TYPE        sgs_srvnam,
         gs_object    TYPE        borident.

  DATA  gs_bc_object TYPE sibflpor.
  DATAgs_service_selection TYPE sgos_sels,
        gt_service_selection TYPE tgos_sels.

*** go_manager related bor object and key 
 " key field for ex. document no    gs_object-objkey  '0000001'.
 " bor object that you created at swo1
  gs_object-objtype 'ZZ_OBJ'.

  CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
      own_logical_system             gs_object-logsys
    EXCEPTIONS
      own_logical_system_not_defined 1
      OTHERS                         2.

*** Which service we're gonna use

"" For Attaching Document
  gp_service 'PCATTA_CREA'.
"" Display and change documents 
*  gp_service = 'VIEW_ATTA'. 

*** Create Instance 
  CREATE OBJECT go_manager
    EXPORTING
      ip_no_commit lp_no_commit
      is_object    gs_object.

*** Start Service
  CALL METHOD go_manager->start_service_direct
    EXPORTING
      ip_service       gp_service
      is_object        gs_object
    EXCEPTIONS
      no_object        1
      object_invalid   2
      execution_failed 3
      OTHERS           4.




 There are test programs to use and understand the functionality. 



GOS_SERV_TOOLS_TEST    
GOS_SERVICE_TEST                    
GOS_TOOLBOX_TEST         



 Hope to post more often. See you.



Monday, December 6, 2010

JAVA

 ABAP developer needs to gain different skills for better understanding of abap beside the other benefits. If you agree and still haven't decided where to start , you should take a look at JAVA. It is probably the most powerful language.

  Using JCO (Java connector) , you can directly call remote enabled functions. Sap Netweaver Developer Studio (NWDS) is the provided ide to develop java applications integrated with sap. You can download JCO and NWDS from SAP marketplace. There is also a book published by SAP Press to begin programming with java.





ABAP vs JAVA : http://enterprisegeeks.com/blog/2009/03/23/egeeks-podcast-episode-12/

Java Beginners : http://download.oracle.com/javase/tutorial/index.html

Netbeans IDE: http://netbeans.org/

JCO : http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/frameset.htm

WDFJ : http://help.sap.com/saphelp_tm60/helpdata/en/15/0d4f21c17c8044af4868130e9fea07/content.htm

Thursday, November 11, 2010

New ABAP Debugger

New ABAP Debugger has many brand new features. It is a mistake not to take a look. If you think so here is the sdn blog ; New ABAP Debugger – Tips and Tricks

Tuesday, February 16, 2010

Change SAP logon screen

Refer to : Note 205487 - Own text on SAPGui logon screen


Go to SE61.



Select General Text , Write ZLOGIN_SCREEN_INFO to Name . Click Change/Create.

You may use icons at the beginning of lines by specifying icon code for example @58@ .

Title lines (can be recognized by format keys starting with a 'U') are highlighted in the display.

Note that there is space on the logon screen for 16 lines for every 45 fixed-font characters or for approximately 60 proportional font characters.

Warning
If you modify screen SAPMSYST 0020 (in older releases), then note that you may only insert text elements.
Changes to the flow logic, for example, by inserting subscreen, force a change in program SAPMSYST.
SAP strongly recommends not changing the system program SAPMSYST because by doing so, serious problems may arise (for example, the dialog logon is generally no longer possible!)



 

Thursday, January 21, 2010

Check If Background Job is Runing

*** We've got a standart FM to check a BG Jobs state SUBST_GET_JOBSTATE
*** Below you can see my code
*** I've the job name MY_JOB_NAME  and i am searching
*** if there is any active job still running for 2 days. if you have
*** program name then just use progname field instead of jobname.

 TABLES : tbtco.

  data : lt_tbtcp type table of tbtcp with header line.
  data : lv_datum type sy-datum.
  data : lv_message type string.
  data: lv_running.

** Check For A reasonable period
  lv_datum = sy-datum - 3.
 
 CLEAR : lv_running.
  select *
    into corresponding fields of table lt_tbtcp
    from tbtcp
   where jobname eq 'MY_JOB_NAME'
      and sdldate gt lv_datum.

  loop at lt_tbtcp.
    select single * from tbtco
           where jobname  = lt_tbtcp-jobname
             and jobcount = lt_tbtcp-jobcount.
    check sy-subrc eq 0.
    if  tbtco-status eq 'R'.
      "JOB is running
       message 'JOB is running' type 'I'.
       lv_running = 'X'.
      exit.
    endif.
  endloop.

if lv_running = 'X'.

  " We have a running job with the specified parameters
endif.

Sunday, January 10, 2010

USER EXISTENCE CHECK

***  Check if user exists :

*** BAPI_USER_EXISTENCE_CHECK
  call function 'BAPI_USER_EXISTENCE_CHECK'
    exporting
      username = p_user
    importing
      return   = ls_return.
if ls_return-number = '124'.
" DOES NOT EXISTS
elseif ls_return-number = '088'.
" EXISTS
endif.

*** SUSR_USER_CHECK_EXISTENCE
  call function 'SUSR_USER_CHECK_EXISTENCE'
       exporting
            user_name            = user_name
       exceptions
            user_name_not_exists = 1
            others               = 2.
if sy-subrc EQ 0.
" EXISTS
endif.

Thursday, January 7, 2010

Get ALV instance From ALV Function

While using ALV function to display ALV grid , there are some restrictions according to oo alv. FM below gives us the chance to use alv instance without restrictions.

****

 data: lr_grid type ref to cl_gui_alv_grid.

  call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    importing
      e_grid = lr_grid.

***

Merge Fieldcat From Dictionary Structure

*** FOR OO ALV

 data : gt_fcat type lvc_t_fcat.

  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name       = 'YOUR_DICT_STRUCTURE'
      i_bypassing_buffer     = 'X'
    changing
      ct_fieldcat            = gt_fcat[]
    exceptions
      inconsistent_interface = 1
      program_error          = 2
      others                 = 3.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

*** FOR ALV FUNCTION

  data : gt_fieldcat type slis_t_fieldcat_alv.


  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = 'YOUR_DICT_STRUCTURE'
      i_bypassing_buffer     = 'X'
    changing
      ct_fieldcat      = gt_fieldcat.

--

Tuesday, January 5, 2010

HR : FM to Find Active Plan Variant

  DATA : gv_plvar TYPE plvar.

  call function 'RH_GET_ACTIVE_WF_PLVAR'
    importing
      act_plvar       = gv_plvar
    exceptions
      no_active_plvar = 1
      others          = 2.

ABAP Date Calculations

 Class CL_HRPAD_DATE_COMPUTATIONS has static methods for most of the date operations you need.

ADD_WEEKS_TO_DATE    Adfd No. of Weeks to Date
ADD_MONTHS_TO_DATE    Adds No. of Months to Date
ADD_YEARS_TO_DATE    Adds No. of Years to Date
SUBTRACT_WEEKS_FROM_DATE    Subtracts No. of Weeks from Date
SUBTRACT_MONTHS_FROM_DATE    Subtracts No. of Months from Date
SUBTRACT_YEARS_FROM_DATE    Subtracts No. of Years from Date
GET_WEEKDAY_NUMBER    Determines Number of Weekday
GET_WEEKDAY_NUMBER_SHIFTED    Determines Number of Weekday (Shifted)
GET_FIRST_DAY_CALENDAR_WEEK    Determines First Day of Calendar Week for Particular Year
GET_LAST_WEEKDAY_NUMBER    Determines Number of Last Weekday
GET_FIRST_DAY_IN_WEEK    Determines First Day of a Week
GET_FIRST_DAY_IN_SHIFTED_WEEK    Determines First Day of Week (Shifted)
GET_FIRST_DAY_PREVIOUS_MONTH    Determines First Day in Previous Month
GET_WEEK    Determines Week in Which Date Lies (Shifted)
GET_SHIFTED_WEEK    Determines Week in Which Date Lies (Shifted)
GET_LAST_DAY_IN_MONTH    Calculates Last Day of Current Month
GET_LAST_DAY_PREVIOUS_MONTH    Determines Last Day of Previous Month
GET_DAYS_PER_YEAR    Determines No. of Days per Year

*** Example

     call method cl_hrpad_date_computations=>get_last_day_in_month
      exporting
        date_in  = lv_begda
      receiving
        date_out = lv_endda.

Wednesday, December 30, 2009

Replace/Remove Specified Characters From String



*** Here we check GV_STRING has any chars other than
*** legal_chars value. If anyone has we replace the value.

DATA legal_chars TYPE string
      VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789.,-*_!?'.
DATA lv_char_value(255)" give max length

lv_char_value gv_string.
CHECK NOT lv_char_value CO legal_chars ).

lv_length strlengv_string ).

DO lv_length TIMES.
  lv_i sy-index 1.
  IF NOT lv_char_value+lv_i(1CO legal_chars.
    "We get the illegal char , do what you want
    lv_char_value+lv_i(1' '.
  ENDIF.
ENDDO.

CLEAR gv_string.
gv_string lv_char_value.

Friday, December 18, 2009

Variant Creation At Runtime



  DATA :   l_variant         TYPE rsvar-variant ,
           l_s_vari_desc     TYPE varid,
           l_t_vari_contents TYPE STANDARD TABLE OF rsparams,
           l_s_vari_contents TYPE rsparams,
           l_t_vari_text     TYPE STANDARD TABLE OF varit,
           l_s_vari_text     TYPE varit.

 l_variant = 'NAME_OF_VARIANT'.

*** Main data
  l_s_vari_desc-mandt = sy-mandt.
  l_s_vari_desc-report = 'REPORT_NAME'.
  l_s_vari_desc-variant = l_variant.
  l_s_vari_desc-flag1 = space.
  l_s_vari_desc-flag2 = space.
  l_s_vari_desc-transport = 'F'.
  l_s_vari_desc-environmnt = 'B'.   "Variant for background
  l_s_vari_desc-protected = space.
  l_s_vari_desc-secu = space.
  l_s_vari_desc-version = '1'.
  l_s_vari_desc-ename = sy-uname.
  l_s_vari_desc-edat = sy-datum.
  l_s_vari_desc-etime = sy-uzeit.
  l_s_vari_desc-aename = space.
  l_s_vari_desc-aedat = space.
  l_s_vari_desc-aetime = space.
  l_s_vari_desc-mlangu = sy-langu.

*** CONTENTS
  l_s_vari_contents-selname = 'S_SELOPT'.
  l_s_vari_contents-kind = 'S'.
  l_s_vari_contents-sign = 'I'.
  l_s_vari_contents-option = 'CP'.
  l_s_vari_contents-low = 'A*'.
  APPEND l_s_vari_contents TO l_t_vari_contents.

  l_s_vari_contents-selname = 'P_BUKRS'.
  l_s_vari_contents-kind = 'P'.
  l_s_vari_contents-sign = 'I'.
  l_s_vari_contents-option = 'EQ'.
  l_s_vari_contents-low = 'AABB'.
  APPEND l_s_vari_contents TO l_t_vari_contents.

*** Description
  l_s_vari_text-mandt = sy-mandt.
  l_s_vari_text-langu = sy-langu.
  l_s_vari_text-report = 'REPORT_NAME'.
  l_s_vari_text-variant = l_variant.
  l_s_vari_text-vtext = l_variant.
  APPEND l_s_vari_text TO l_t_vari_text.

*** Del variant if any exists with the same name (Optional)
  CALL FUNCTION 'RSAQ_DELETE_ONE_VARIANT'
    EXPORTING
      report                    = 'REPORT_NAME'
      variant                   = l_variant
*   IMPORTING
*     SUBC                      =
   EXCEPTIONS
     not_authorized            = 1
     not_executed              = 2
     no_report                 = 3
     report_not_existent       = 4
     report_not_supplied       = 5
     variant_locked            = 6
     OTHERS                    = 7
            .


  CALL FUNCTION 'RS_CREATE_VARIANT'
    EXPORTING
      curr_report               = 'REPORT_NAME'
      curr_variant              = l_variant
      vari_desc                 = l_s_vari_desc
    TABLES
      vari_contents             = l_t_vari_contents
      vari_text                 = l_t_vari_text
    EXCEPTIONS
      illegal_report_or_variant = 1
      illegal_variantname       = 2
      not_authorized            = 3
      not_executed              = 4
      report_not_existent       = 5
      report_not_supplied       = 6
      variant_exists            = 7
      variant_locked            = 8
      OTHERS                    = 9.




Input parameters for ENQUEUE/DEQUEUE Functions . - SAP Lock Mechanism -

A closer look at the lock FM parameters which is used commonly by transactional processes.

****************************************************

X_

A further parameter X_ that defines the lock behavior when the initial value is passed exists for every lock field . If the initial value is assigned to and X_, then a generic lock is initialized with respect to . If is assigned the initial value and X_ is defined as X, the lock is set with exactly the initial value of .

Well , this means if you need a parameters initial value to lock , you must set X_ = 'X' for this purpose otherwise it locks entire values.

_SCOPE

1: Locks or lock releases are not passed to the update program. The lock is removed when the transaction is ended.
2: The lock or lock release is passed to the update program. The update program is responsible for removing the lock. The interactive program with which the lock was requested no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
3: The lock or lock release is also passed to the update program. The lock must be removed in both the interactive program and in the update program. This is the standard setting for the DEQUEUE function module.

Meaning of the _SCOPE Values
Value
Description
_SCOPE = 1
The lock belongs only to the dialog owner (owner_1), and therefore only exists in the dialog transaction. The DEQUEUE call or the end of the transaction, not COMMIT WORK or ROLLBACK WORK, cancels the lock.
_SCOPE = 2
The lock belongs to the update owner (owner_2) only. Therefore, the update inherits the lock when CALL FUNCTION ‘…‘ IN UPDATE TASK and COMMIT WORK are called. The lock is released when the update transaction is complete. You can release the lock before it is transferred to the update using ROLLBACK WORK. COMMIT WORK has no effect, unless CALL FUNCTION ‘…‘ IN UPDATE TASK has been called.
_SCOPE = 3
The lock belongs to both owners (owner_1 and owner_2). In other words, it combines the behavior of both. This lock is canceled when the last of the two owners has released it.


MODE_

S (read lock) 
E (write lock) 
X (extended write lock)
O (optimistic lock)

Locks Modes
Type of Lock
Lock mode
Description
Shared lock
S (Shared)
Several users (transactions) can access locked data at the same time in display mode. Requests from further shared locks are accepted, even if they are from different users. An exclusive lock set on an object that already has a shared lock will be rejected.
Exclusive lock
E (Exclusive)
An exclusive lock protects the locked object against all types of locks from other transactions. Only the same lock owner can reset the lock (accumulate).
Exclusive but not cumulative lock
X (eXclusive non-cumulative)
Whereas exclusive locks can be requested several times by the same transaction and released one by one, an exclusive, non-cumulative lock can only be requested once by the same transaction. Each further lock request will be rejected.
Optimistic lock
O (Optimistic)
Optimistic locks initially behave like shared locks and can be converted into exclusive locks. See Optimistic Locks.

_COLLECT

Initial Value: The lock request or lock release is sent directly to the lock server.
X: The lock request or lock release is placed in the local lock container. The lock requests and lock releases collected in this lock container can then be sent to the lock server at a later time as a group by calling the function module FLUSH_ENQUEUE.

_WAIT

Initial Value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is triggered.
X: If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed since the first lock attempt. The waiting time and the time limit are defined by profile parameters.

_SYNCHRON

If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table. Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the lock is removed, the entry in the lock table may still exist.

Exceptions of the ENQUEUE Function Module

FOREIGN_LOCK: A competing lock already exists. You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.
SYSTEM_FAILURE: This exception is triggered when the lock server reports that a problem occurred while setting the lock. In this case, the lock could not be set.

 Ref : The SAP Lock Concept


 Ref : SAP Documentation LOCK OBJECTS

Thursday, December 17, 2009

Scheduling Background Job At Runtime - ABAP

data : gv_job_name type btcjob ,
         gv_jobcount type btcjobcnt,
         gv_variant type rsvar-variant.
constants : gc_bg_repid type sy-repid value 'ZZZZ_PROGRAM_NAME'.
data : gv_step like tbtcjob-stepcount.

*** Simply we initiate the operation
gv_job_name = 'NAMEOFJOB'.
call function 'JOB_OPEN'
exporting
jobname = gv_job_name
importing
jobcount = gv_jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.


*** Submit the report and needed variant name
gv_variant = 'VARIANT111'.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
*** here gv_step equals to 1 as a first step
*** You can multiple steps by using the job_submit function

*** Use Another variant or report for the second step
gv_variant = 'VARIANT222'.

call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.

*** here gv_step equals to 2 as a second step
*** Finally release the job.

*** According to your scheduling options lots of input

*** parameters exist inside the function
*** You've got your job number

call function 'JOB_CLOSE'
exporting
jobcount = gv_jobcount
jobname = gv_job_name
strtimmed = 'X'
* IMPORTING
* JOB_WAS_RELEASED =
* CHANGING
* RET =
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
others = 9.

Sunday, December 13, 2009

Flex Builder Configuration - Changing Locale Setting

Add the following lines inside the FlexBuilder.ini file.

---------------------------

-Duser.language=en
-Duser.location=us
---------------------------

Tuesday, November 24, 2009

Set Listbox Values At Selection Screen

When you hit F8 , the p_par will have the key fields value of selected list item.

*** Type Pool
type-pools : vrm.
.
.
*** Her's the definition of listbox parameter
parameters : p_par type mara-mtart as listbox visible length 15.
.
.

*** Event Block
at selection-screen output.
  perform at_sel_output.

.
.
.

*&---------------------------------------------------------------------*
*&      Form  at_sel_output
*&---------------------------------------------------------------------*
form at_sel_output.

  data : lt_list  type vrm_values with header line .

  lt_list-key = 'K1'.
  lt_list-text = ' First One'.
  append lt_list.
  lt_list-key = 'K2'.
  lt_list-text = ' Second One'.
  append lt_list.
  lt_list-key = 'K3'.
  lt_list-text = ' Third One'.
  append lt_list.

  call function 'VRM_SET_VALUES'
    exporting
      id              = 'P_PAR'
      values          = lt_list[]
    exceptions
      id_illegal_name = 1
      others          = 2.

endform.                    "at_sel_output

Thursday, November 19, 2009

Get print parameters and submit report to sap spool

      DATA: p_parameters TYPE pri_params,
            a_parameters TYPE arc_params,
            valid(1).

      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          archive_mode           = '1'  " Just print
        IMPORTING
          out_parameters         = p_parameters
          out_archive_parameters = a_parameters
          valid                  = valid
        EXCEPTIONS
          invalid_print_params   = 2
          OTHERS                 = 4.

      CHECK valid EQ 'X'.

  SUBMIT zz_your_report_name WITH p_submit EQ 'X'               
                 TO SAP-SPOOL
                 SPOOL PARAMETERS p_parameters
                 ARCHIVE PARAMETERS a_parameters
                 WITHOUT SPOOL DYNPRO.

Sunday, November 15, 2009

Smartforms related standart demo programs

SF_BATCH_GENERATE              Program for Generating SMART FORMS in Batch
SF_EXAMPLE_01                         Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_01_BACKUP       Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02                         Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02_BACKUP       Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03                         Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03_BACKUP       Sample Program for Form Printing Using Smart Forms
SF_TOTALS                                  Examples for Totalling Different Currencies
SF_XSF_DEMO                            Smart Forms: XSF Output - Demo Program
SF_XSF_DEMO_MAIL                Send Form and Graphics by E-Mail
SF_XSF_DEMO2
SF_XSF_DEMO3