[Correction] SAP call an external program method

In SAP in a procedure call an external program in two ways:
 
1. Call transaction <tcode>
BDC is common in the program.
  CALL TRANSACTION tcode
        USING bdcdata
        MODE  p_mode
        UPDATE c_update
        MESSAGES INTO messtab.
mode has the following optional values.

carried out

mode  

effect

"A"

All input display screen, if the screen contains the function code in bdc_tab, a small window displays the function code appears. It is the default, if not below the value specified, are considered to be A.

"E"

Display screen only when an error occurs, the user can correct the data, the program can continue processing as amended.

"N"

Silent mode does not display the screen. If you reach the breakpoint is called the transaction, the system processing is terminated, and set up some system fields. sy-subrc  to 1001, SY-msgty  as "S", SY-msgid  is "00", SY-msgno  as "344", SY-MSGV1  as "SAPMSSY3", SY-msgv2  as "0131."

"P"

Debug mode screen is not displayed. If you reach the breakpoint is called the transaction, the system will automatically go to ABAP debugger, this approach is mainly used for the debugging process.

update has the following optional values:

Update Mode

effect

"A"

Asynchronous update. Updated called program implemented in accordance with the statement COMMIT WORK AND WAIT and additional ways not specified. That is, data is updated into the update queue, performed by another special update process, once the main program will continue to submit data, submitted updated regardless of whether the execution is completed. This approach is more suitable to use a large number of update transaction code designating data, such as maintenance of the master data and the like.

"S"

Synchronization Update. Updated called program execution in accordance with the specified COMMIT WORK AND WAIT statement and additional ways. That is, data is updated into the update queue, executed by a dedicated update process, but the main program will wait until the data submitted complete and return the result information before continuing execution. This embodiment is more suitable for data consistency requirements are relatively high, continuous processing of a plurality of different transaction codes.

"L"

Local update. Updated called program executed in the manner of the implementation of SET UPDATE TASK LOCAL statement. In other words, the data update process is completed in the main program is located, it is called the main program must wait until the transaction is complete before continuing execution.

 
2. Submit <program> and return
Call program:
REPORT  ZTEST_CALL_PROG.
DATA: BEGIN OF w_data,
  fid1 TYPE string,
  num1 type i,
  num2 type i,
END OF w_data.
DATA: T_OUT LIKE W_DATA OCCURS 0 WITH HEADER LINE.
Do 10 TIMES.
  if sy-index < 4.
    t_out-fid1 = 'A'.
    t_out-num1 = sy-index.
    t_out-num2 = sy-index + 1.
  elseif his index <7.
    t_out-fid1 = 'B'.
    t_out-num1 = sy-index + 1.
    t_out-num2 = sy-index + 2.
  else.
    t_out-fid1 = 'C'.
    t_out-num1 = sy-index.
    t_out-num2 = sy-index - 1.
  ENDIF.
  append t_out.
  ENDDO.
  export t_out to within 'T_OUT'. "Table t_out of memory MEMORY id id is 'T_OUT', the program is called data acquired from here.
  SUBMIT zwrite_date and RETURN. "Here you can also use submit zwrite_data with WITH s_aufnr = p_aufnr
                                     "WITH s_mode = 'N value passed to the called procedure.
  write: / 'justin'.
 
 
The program is called, to obtain data to be processed in the ABAP memory storage from the caller.
REPORT  ZWRITE_DATE.
data: BEGIN OF w_data,
  fid1 type string,
  num1 type i,
  num2 type i,
 END OF w_data.
 data: t_out LIKE w_data OCCURS 0 WITH HEADER LINE.
 import t_out from MEMORY id 'T_OUT'.
 FREE MEMORY ID 'T_OUT'. "Clear MEMORY ID is 'T_OUT' content.
 loop at t_out.
   write: / ' ', t_out-fid1, t_out-num1, t_out-num2.
 ENDLOOP.
 write: sy-uline.
 
 
Other example:
   EXPORT rm16_lgort  FROM l_lgort

          rm16_werks  FROM p_plwrk
          rm16_matnr  FROM p_matnr  TO  MEMORY ID 'ZPHRRM13'.
  SUBMIT zphrrm13 AND RETURN.
  IMPORT mdezx mdpsx mdkp mdsta mdstal FROM MEMORY ID 'ZPHRRM13'

 

 
Released 2018 original articles · won praise 3957 · Views 10,350,000 +

Guess you like

Origin blog.csdn.net/zhongguomao/article/details/46827099