Application Development 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: 

How to write call transaction for bdc generated code??

Former Member
0 Kudos
82

Hi experts,

How to write call transaction code for the bdc generated code perform bdc_transaction?? When i try to write the code and execute, its creating some problem in inserting datas into the internal table...

Can you please help me out in this regard. Thanks in advance.

POINTS PROMISED.

Regards,

buvana

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
52

Very simple, basically, you keep the coding for the filling of the screen fields and ok_codes, then add your own CALL TRANSACTION statement.

data: messtab like bdcmsgcoll occurs 0 with header line.
data: bdcdata like bdcdata occurs 20 with header line.

  perform bdc_dynpro      using 'SAPLCSDI' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29N-STLAN'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29N-MATNR'
                          i_bom-matnr.
  perform bdc_field       using 'RC29N-WERKS'
                          i_bom-werks.
  perform bdc_field       using 'RC29N-STLAN'
                                '1'.
  perform bdc_field       using 'RC29N-DATUV'
                          i_bom-datum.
  perform bdc_dynpro      using 'SAPLCSDI' '0150'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POSNR(01)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=FCNP'.
  perform bdc_dynpro      using 'SAPLCSDI' '0140'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POSTP(02)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29P-AUSKZ(02)'
                                'X'.
  perform bdc_field       using 'RC29P-POSNR(02)'
                           i_bom-posnr.
  perform bdc_field       using 'RC29P-IDNRK(02)'
                           i_bom-idnrk.
  perform bdc_field       using 'RC29P-MENGE(02)'
                           i_bom-menge.
  perform bdc_field       using 'RC29P-MEINS(02)'
                           i_bom-meins.
  perform bdc_field       using 'RC29P-POSTP(02)'
                           i_bom-postp.


  call transaction 'CS02' using bdcdata mode 'N'
                               update 'S'
                               messages into messtab.

  commit work and wait.
  clear: bdcdata, messtab.
  refresh: bdcdata, messtab.



************************************************************************
*      Form  BDC_DYNPRO
************************************************************************
form bdc_dynpro using  program dynpro.

  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata.

endform.

************************************************************************
*      Form  BDC_FIELD
************************************************************************
form bdc_field using fnam fval.

  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata.

endform.

Regards,

Rich Heilman

1 REPLY 1

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
53

Very simple, basically, you keep the coding for the filling of the screen fields and ok_codes, then add your own CALL TRANSACTION statement.

data: messtab like bdcmsgcoll occurs 0 with header line.
data: bdcdata like bdcdata occurs 20 with header line.

  perform bdc_dynpro      using 'SAPLCSDI' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29N-STLAN'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29N-MATNR'
                          i_bom-matnr.
  perform bdc_field       using 'RC29N-WERKS'
                          i_bom-werks.
  perform bdc_field       using 'RC29N-STLAN'
                                '1'.
  perform bdc_field       using 'RC29N-DATUV'
                          i_bom-datum.
  perform bdc_dynpro      using 'SAPLCSDI' '0150'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POSNR(01)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=FCNP'.
  perform bdc_dynpro      using 'SAPLCSDI' '0140'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29P-POSTP(02)'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29P-AUSKZ(02)'
                                'X'.
  perform bdc_field       using 'RC29P-POSNR(02)'
                           i_bom-posnr.
  perform bdc_field       using 'RC29P-IDNRK(02)'
                           i_bom-idnrk.
  perform bdc_field       using 'RC29P-MENGE(02)'
                           i_bom-menge.
  perform bdc_field       using 'RC29P-MEINS(02)'
                           i_bom-meins.
  perform bdc_field       using 'RC29P-POSTP(02)'
                           i_bom-postp.


  call transaction 'CS02' using bdcdata mode 'N'
                               update 'S'
                               messages into messtab.

  commit work and wait.
  clear: bdcdata, messtab.
  refresh: bdcdata, messtab.



************************************************************************
*      Form  BDC_DYNPRO
************************************************************************
form bdc_dynpro using  program dynpro.

  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata.

endform.

************************************************************************
*      Form  BDC_FIELD
************************************************************************
form bdc_field using fnam fval.

  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata.

endform.

Regards,

Rich Heilman