ABAP SUMBIT程序的程序里也有SUBMIT的处理方式
一般来说,程序调用其他程序时候可以用submit来传参取数。网上也有很多种例子。
一般来说使用下面代码取内存获得内表数据,当radiobutton时候要全部传参
CL_SALV_BS_RUNTIME_INFO=>SET( EXPORTING DISPLAY = ABAP_FALSE METADATA = ABAP_FALSE DATA = ABAP_TRUE ). SUBMIT ZMMRP070 WITH P_IMPORT = '' "radiobutton 传参要用‘’ WITH P_QUERY = '' WITH P_DATA = 'X' * WITH S_MATNR IN S_MATNR WITH S_MATNR IN LR_MATNR EXPORTING LIST TO MEMORY AND RETURN. IF SY-SUBRC = 0. TRY. CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF( IMPORTING R_DATA = LR_PAY_DATA ). ASSIGN LR_PAY_DATA->* TO <LT_PAY_DATA>. CATCH CX_SALV_BS_SC_RUNTIME_INFO. MESSAGE `Unable to retrieve ALV data` TYPE 'E'. ENDTRY. ENDIF. CL_SALV_BS_RUNTIME_INFO=>CLEAR_ALL( ). LOOP AT <LT_PAY_DATA> ASSIGNING FIELD-SYMBOL(<FS_MEMORY>). MOVE-CORRESPONDING <FS_MEMORY> TO WA_STOCK. APPEND WA_STOCK TO IT_STOCK. CLEAR:WA_STOCK. ENDLOOP. ENDIF.
但是当调用的程序里也有submit的时候,内存就取得不对了,专家说这个时候要采取多线程任务,当然这个不懂,后面采取了MEMORY ID的方法。
具体操作如下:
在被调用的程序里定义一个CONSTANTS: G_MEMORY(30) VALUE 'ZSYPJXS'."三月平均销售内存
在处理完内表后,加一个
FREE MEMORY ID G_MEMORY.
"将结果导出到主调用程序
EXPORT IT_SMZQBB FROM IT_SMZQBB TO MEMORY ID G_MEMORY
在主程序里接受内存
CONSTANTS: G_MEMORY(30) VALUE 'ZSYPJXS'."三月平均销售内存 "也要定义好相同名字的名字 DATA:IT_SMZQBB111 TYPE STANDARD TABLE OF TY_SMZQBB, WA_SMZQBB111 TYPE TY_SMZQBB."主程序定义好相同的接受数据的内表结构 FIELD-SYMBOLS : <LT_PAY_DATA> TYPE ANY TABLE . FIELD-SYMBOLS : <LT_TEST> TYPE ANY . "LIKE LINE OF it_tab . DATA LR_PAY_DATA TYPE REF TO DATA. RANGES: S_MATNR1 FOR ZTMM021-MATNR. S_MATNR1-SIGN = 'I'. S_MATNR1-OPTION = 'EQ'. S_MATNR1-LOW = IT_PCLJ-MATNR. APPEND S_MATNR1. CLEAR: S_MATNR1. CLEAR LR_PAY_DATA. UNASSIGN <LT_PAY_DATA>. CL_SALV_BS_RUNTIME_INFO=>SET( EXPORTING DISPLAY = ABAP_FALSE METADATA = ABAP_FALSE DATA = ABAP_TRUE ). SUBMIT ZSDRP120 WITH S_MATNR IN S_MATNR1 WITH A = '' WITH B = 'X' WITH C = '' WITH S = '' WITH SS = 'X' WITH D = '' WITH Z_BACK = 'X' *EXPORTING LIST TO MEMORY AND RETURN. AND RETURN. *VIA SELECTION-SCREEN. "VIA SELECTION-SCREEN 表示显示被调用的屏幕 "从被调用程序中导入结果 IMPORT IT_SMZQBB TO IT_SMZQBB111 FROM MEMORY ID G_MEMORY. FREE MEMORY ID G_MEMORY.
这个时候数据会被传到主程序的
IT_SMZQBB111里,就可以进行处理了。