Skip to Content
0
Feb 09, 2007 at 07:59 AM

batch input in my own program

165 Views

Hi experts,

I have a problem with the using of BDC (batch input).

I created a "executable" BDC program and want to use it in my own program. I can view my entries in a table control and have a button to push the data from "it_input" with the BDC perform instructions into the R/3.

MODULE pai_0100 INPUT.
  IF sy-ucomm = 'BACK' OR
     sy-ucomm = 'EXIT' OR
     sy-ucomm = 'CANCEL'.
     LEAVE PROGRAM.

  ELSE.

  DATA: l_date TYPE sy-datum.

  include bdcrecx1.

  perform open_group.

  LOOP AT it_input.

  perform bdc_dynpro      using 'SAPMM07M' '0400'.
  perform bdc_field       using 'BDC_CURSOR'
                                'MKPF-BLDAT'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'MKPF-BLDAT'
                                l_date.
  perform bdc_field       using 'MKPF-BUDAT'
                                l_date.
  perform bdc_field       using 'RM07M-BWARTWA'
                                bwart.
  perform bdc_field       using 'RM07M-WERKS'
                                werks.
  perform bdc_field       using 'RM07M-LGORT'
                                lgort.
  perform bdc_field       using 'XFULL'
                                'X'.
  perform bdc_field       using 'RM07M-WVERS2'
                                'X'.
  perform bdc_dynpro      using 'SAPMM07M' '0421'.
  perform bdc_field       using 'BDC_CURSOR'
                                'MSEG-CHARG(01)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=BU'.
  perform bdc_field       using 'MSEG-MATNR(01)'
                                it_input-matnr.
  perform bdc_field       using 'MSEG-ERFMG(01)'
                                it_input-erfmg.
  perform bdc_field       using 'DKACB-FMORE'
                                'X'.
  perform bdc_dynpro      using 'SAPLKACB' '0002'.
  perform bdc_field       using 'BDC_CURSOR'
                                'COBL-KOSTL'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=ENTE'.
  perform bdc_field       using 'COBL-KOSTL'
                                kostl.
  perform bdc_dynpro      using 'SAPLKACB' '0002'.
  perform bdc_field       using 'BDC_CURSOR'
                                'COBL-KOSTL'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=ENTE'.
  perform bdc_field       using 'COBL-KOSTL'
                                kostl.
  perform bdc_transaction using 'MB1A'.

  ENDLOOP.

  perform close_group.


  ENDIF.
ENDMODULE.

But I get an error: "before statement AT, the IF statement has to be closed with ENDIF."

That means I cannot put my BDC into the IF-statement where I ask which button is pressed. The AT statement determine in the "include".

  IF sy-ucomm = 'BACK' OR
     sy-ucomm = 'EXIT' OR
     sy-ucomm = 'CANCEL'.
     LEAVE PROGRAM.

  ELSE.

  DATA: l_date TYPE sy-datum.

  include bdcrecx1.

Has anybody an idea? Do I have to put my BDC into an new REPORT, and call this report with SUBMIT? But then I have to pass the complete it_input table and some variables...

Regards,

Steffen