ABAP程序相互调用--SUBMIT
生活随笔
收集整理的這篇文章主要介紹了
ABAP程序相互调用--SUBMIT
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
(1) 調用其他程序:
* Trigger the IDOCSUBMIT zpcppmd001_idoc AND RETURN.(2) 調用其他程序參數(shù)傳遞參數(shù):
*當被調用的程序的屏幕有輸入?yún)?shù)時: SUBMIT zreport with p_param1 = 'value1'with p_param2 = 'value2'. *當要傳遞一個內表到被調用的程序時,需要用SAP MEMORY或者ABAP MEMORY: *在調用的程序中: EXPORT it_tab TO MEMORY 'Z_MEMORY'. *在被調用的程序中: IMPORT T_ITAB FROM MEMORY 'Z_MEMORY'.(3) RANGE表:
*Code used to populate 'select-options' & execute reportDATA: seltab type table of rsparams,seltab_wa like line of seltab. seltab_wa-selname = 'PNPPERNR'.seltab_wa-sign = 'I'.seltab_wa-option = 'EQ'. * load each personnel number accessed from the structure into* parameters to be used in the reportloop at pnppernr.seltab_wa-low = pnppernr-low.append seltab_wa to seltab.endloop.SUBMIT zreport with selection-table seltabvia selection-screen.(4)其他情況:
*Submit report and return to current program afterwards SUBMIT zreport AND RETURN. *Submit report via its own selection screen SUBMIT zreport VIA SELECTION-SCREEN. *Submit report using selection screen variant SUBMIT zreport USING SELECTION-SET 'VARIANT1'. REPORT ZPPR0051.TABLES:AUFM.DATA: IT_SELTAB TYPE TABLE OF RSPARAMS,IW_SELTAB LIKE LINE OF IT_SELTAB.SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: S_WERKS FOR AUFM-WERKS OBLIGATORY NO INTERVALS,S_AUFNR FOR AUFM-AUFNR. SELECTION-SCREEN END OF BLOCK BLK.*----------------------------------------------------------------------* * START-OF-SELECTION. *----------------------------------------------------------------------*START-OF-SELECTION.LOOP AT S_WERKS.IW_SELTAB-SELNAME = 'S_WERKS'.IW_SELTAB-SIGN = S_WERKS-SIGN .IW_SELTAB-OPTION = S_WERKS-OPTION.IW_SELTAB-LOW = S_WERKS-LOW.APPEND IW_SELTAB TO IT_SELTAB. ENDLOOP.LOOP AT S_AUFNR .IW_SELTAB-SELNAME = 'S_AUFNR'.IW_SELTAB-SIGN = S_AUFNR-SIGN .IW_SELTAB-OPTION = S_AUFNR-OPTION.IW_SELTAB-LOW = S_AUFNR-LOW.IW_SELTAB-HIGH = S_AUFNR-HIGH.APPEND IW_SELTAB TO IT_SELTAB. ENDLOOP.SUBMIT ZPPR0015 WITH SELECTION-TABLE IT_SELTAB.?*---------------------------------------------------------------------------
1、最普通的用法*Code used to execute a report SUBMIT Zreport.2、帶select-options程序的Submit的用法*Code used to populate 'select-options' & execute report DATA: seltab type table of rsparams,seltab_wa like line of seltab.seltab_wa-selname = 'PNPPERNR'.seltab_wa-sign = 'I'.seltab_wa-option = 'EQ'.* load each personnel number accessed from the structure into* parameters to be used in the reportloop at pnppernr.seltab_wa-low = pnppernr-low.append seltab_wa to seltab.endloop.SUBMIT zreport with selection-table seltabvia selection-screen.3、帶parameters程序的Submit的用法*Code used to populate 'parameters' & execute reportSUBMIT zreport with p_param1 = 'value' with p_param2 = 'value'.4、其他情況*Submit report and return to current program afterwardsSUBMIT zreport AND RETURN.*Submit report via its own selection screen SUBMIT zreport VIA SELECTION-SCREEN.*Submit report using selection screen variant SUBMIT zreport USING SELECTION-SET 'VARIANT1'.*Submit report but export resultant list to memory, rather than *it being displayed on screen SUBMIT zreport EXPORTING LIST TO MEMORY. * Once report has finished and control has returned to calling * program, use function modules LIST_FROM_MEMORY, WRITE_LIST and * DISPLAY_LIST to retrieve and display report.*Example Code (Retrieving list from memory) DATA BEGIN OF itab_list OCCURS 0. INCLUDE STRUCTURE abaplist. DATA END OF itab_list.DATA: BEGIN OF vlist OCCURS 0, filler1(01) TYPE c, field1(06) TYPE c, filler(08) TYPE c, field2(10) TYPE c, filler3(01) TYPE c, field3(10) TYPE c, filler4(01) TYPE c, field4(3) TYPE c, filler5(02) TYPE c, field5(15) TYPE c, filler6(02) TYPE c, field6(30) TYPE c, filler7(43) TYPE c, field7(10) TYPE c, END OF vlist.SUBMIT zreport EXPORTING LIST TO MEMORY.CALL FUNCTION 'LIST_FROM_MEMORY' TABLES listobject = itab_list EXCEPTIONS not_found = 4 OTHERS = 8.CALL FUNCTION 'LIST_TO_ASCI' EXPORTING list_index = -1 TABLES listasci = vlist listobject = itab_list EXCEPTIONS empty_list = 1 list_index_invalid = 2 OTHERS = 3.IF sy-subrc NE '0'. WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc. ENDIF.5、Submit為后臺執(zhí)行*Submit report as job(i.e. in background) data: jobname like tbtcjob-jobname value ' TRANSFER TRANSLATION'. data: jobcount like tbtcjob-jobcount, host like msxxlist-host. data: begin of starttime. include structure tbtcstrt. data: end of starttime. data: starttimeimmediate like btch0000-char1.* Job open call function 'JOB_OPEN' exporting delanfrep = ' ' jobgroup = ' ' jobname = jobname sdlstrtdt = sy-datum sdlstrttm = sy-uzeit importing jobcount = jobcount exceptions cant_create_job = 01 invalid_job_data = 02 jobname_missing = 03. if sy-subrc ne 0. "error processing endif.* Insert process into job SUBMIT zreport and return with p_param1 = 'value' with p_param2 = 'value' user sy-uname via job jobname number jobcount. if sy-subrc > 0. "error processing endif.* Close job starttime-sdlstrtdt = sy-datum + 1. starttime-sdlstrttm = '220000'. call function 'JOB_CLOSE' exporting event_id = starttime-eventid event_param = starttime-eventparm event_periodic = starttime-periodic jobcount = jobcount jobname = jobname laststrtdt = starttime-laststrtdt laststrttm = starttime-laststrttm prddays = 1 prdhours = 0 prdmins = 0 prdmonths = 0 prdweeks = 0 sdlstrtdt = starttime-sdlstrtdt sdlstrttm = starttime-sdlstrttm strtimmed = starttimeimmediate targetsystem = host exceptions cant_start_immediate = 01 invalid_startdate = 02 jobname_missing = 03 job_close_failed = 04 job_nosteps = 05 job_notex = 06 lock_failed = 07 others = 99. if sy-subrc eq 0. "error processing endif.?
程序間獲取ALV數(shù)據(jù)的兩種方法: 方法1:通過修改SUBMIT的目標程序,把內表EXPORT到內存,SUBMIT后IMPORT ,該方法需要修改目標程序,可以任意設置目標程序的中斷點; 方法2:SUBMIT前屏蔽ALV GRID的顯示,SUBMIT,然后調用CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF方法獲取數(shù)據(jù),該方法不需要修改目標程序,但不能設置目標程序的中斷點,需顯示ALV的函數(shù)執(zhí)行完畢方可獲取到數(shù)據(jù)。 示例: START-OF-SELECTION. PERFORM GET_DATA. *&———————————————————————* *& Form GET_DATA *&———————————————————————* * text *———————————————————————-* * –> p1 text * <– p2 text *———————————————————————-* FORM GET_DATA. DATA:LS_DATA TYPE REF TO DATA. FIELD-SYMBOLS: <LT_DATA> TYPE TABLE, <L_DATA> TYPE DATA.CL_SALV_BS_RUNTIME_INFO=>SET( DISPLAY = '' METADATA = '' DATA = 'X' ).SUBMIT ZMM000000 WITH ZBUDAT IN ZBUDAT AND RETURN.TRY. CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF( IMPORTING R_DATA = LS_DATA ). ASSIGN LS_DATA->* TO <LT_DATA>.CATCH CX_SALV_BS_SC_RUNTIME_INFO. MESSAGE 'UNABLE TO RETRIEVE ALV DATA' TYPE 'E'.ENDTRY.CL_SALV_BS_RUNTIME_INFO=>CLEAR_ALL( ).LOOP AT <LT_DATA> ASSIGNING <L_DATA>. MOVE-CORRESPONDING <L_DATA> TO GT_TAB. APPEND GT_TAB. ENDLOOP. ENDFORM.?
轉載于:https://www.cnblogs.com/mingdashu/p/5609503.html
總結
以上是生活随笔為你收集整理的ABAP程序相互调用--SUBMIT的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言程序设计做题笔记之C语言基础知识(
- 下一篇: Beta阶段项目总结