Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

batch input in my own program

former_member183924
Active Participant
0 Likes
929

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
757

use include before calling module pai. hopefully this should work.

Reward me if it works.

5 REPLIES 5
Read only

Former Member
0 Likes
758

use include before calling module pai. hopefully this should work.

Reward me if it works.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
757

move your "include bdcrecx" to the end of your program, else its FORM and ENDFORM are in the middle of your IF ENDIF. And Abap don't like it

Regards.

Read only

andreas_mann3
Active Contributor
0 Likes
757

hi,

put your includes in your module-pool (Rahmenprogramm)

A.

Message was edited by:

Andreas Mann

Read only

Former Member
0 Likes
757

Dear Steffen,

It might be because ome restriction in PAI Module. Use form-perform instead.

It should be like this:

MODULE pai_0100 INPUT.

IF sy-ucomm = 'BACK' OR

sy-ucomm = 'EXIT' OR

sy-ucomm = 'CANCEL'.

LEAVE PROGRAM.

ELSE.

PERFORM form_mybdc.

ENDIF.

ENDMODULE.

Then in some F01 programs, create the form

FORM form_mybdc.

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'

... etc.

ENDLOOP.

perform close_group.

ENDFORM.

Hope this help ...

Regards,

Dian

Read only

Former Member
0 Likes
757

Hi,

You will have to place the Include bdcrecx1 statement at the top of ur program.

regards,

Mahesh