Posted: Wed Sep 05, 2007 6:53 pm Post subject: Create BOM using BDC
Author: Maheshwar K
Code:
Data: lv_flag type c,
Lv_index(4) type c value '0000'.
Loop at internal table.
If lv_flag eq space.
Lv_flag = 'X'. "For the first record
Else.
lv_index = lv_index + 10. "And for the rest of the records
Endif.
Endloop.
*&---------------------------------------------------------------------*
*& Form create_bom
*&---------------------------------------------------------------------*
* This form creates the BOM
*----------------------------------------------------------------------*
FORM create_bom USING value(uv_idoc_contrl_docnum) TYPE edidc-docnum
ut_e1stzum TYPE tt_e1stzum
ut_z1eqst TYPE tt_z1eqst
ut_e1stkon TYPE tt_e1stkon
ut_e1stpon TYPE tt_e1stpon
* begin GSK20060915i
CHANGING ct_idoc_status TYPE tt_bdidocstat.
* end GSK20060915i
*-- L O C A L D E C L A R A T I O N S
DATA: ls_e1stzum TYPE ts_e1stzum,
ls_z1eqst TYPE ts_z1eqst,
ls_e1stkon TYPE ts_e1stkon,
ls_e1stpon TYPE ts_e1stpon,
ls_messtab TYPE ts_messtab,
lt_messtab TYPE tt_messtab,
lt_bdcdata TYPE tt_bdcdata,
* lt_idoc_status TYPE tt_bdidocstat, "GSK20060915d
lv_mode TYPE c VALUE 'N', "NO SCREENS
lv_flag TYPE c,
lv_index(4) TYPE c VALUE '0010'.
SORT ut_z1eqst BY psgnum.
SORT ut_e1stkon BY psgnum.
LOOP AT ut_e1stzum INTO ls_e1stzum.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0200'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29N-EQUNR'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29N-EQUNR'
ls_z1eqst-equnr
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29N-WERKS'
ls_z1eqst-werks
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29N-STLAN'
ls_e1stzum-stlan
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29N-DATUV'
ls_e1stkon-datuv
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0110'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29K-BMENG'
'1'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29K-STLST'
'1'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29K-EXSTL'
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0111'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29K-LABOR'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
LOOP AT ut_e1stpon INTO ls_e1stpon WHERE psgnum EQ ls_e1stzum-segnum.
IF lv_flag EQ space.
lv_flag = 'X'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSTP(01)'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-IDNRK(01)'
ls_e1stpon-idnrk
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MENGE(01)'
ls_e1stpon-menge
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MEINS(01)'
ls_e1stpon-meins
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-POSTP(01)'
ls_e1stpon-postp
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0130'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-POSNR'
'0010'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-IDNRK'
ls_e1stpon-idnrk
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MENGE'
ls_e1stpon-menge
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MEINS'
ls_e1stpon-meins
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0131'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POTX1'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-SANKA'
'X'
CHANGING lt_bdcdata[].
ELSE.
lv_index = lv_index + 10.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR(01)'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'=FCNP'
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSTP(02)'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-IDNRK(02)'
ls_e1stpon-idnrk
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MENGE(02)'
ls_e1stpon-menge
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MEINS(02)'
ls_e1stpon-meins
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-POSTP(02)'
ls_e1stpon-postp
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0130'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-POSNR'
lv_index
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-IDNRK'
ls_e1stpon-idnrk
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MENGE'
ls_e1stpon-menge
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-MEINS'
ls_e1stpon-meins
CHANGING lt_bdcdata[].
PERFORM bdc_dynpro USING 'SAPLCSDI' '0131'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POTX1'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'RC29P-SANKA'
'X'
CHANGING lt_bdcdata[].
ENDIF.
ENDLOOP. "LOOP AT ut_e1stpon INTO ls_e1stpon
CLEAR: lv_flag, lv_index.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR(02)'
CHANGING lt_bdcdata[].
PERFORM bdc_field USING 'BDC_OKCODE'
'=FCBU'
CHANGING lt_bdcdata[].
* C A L L T R A N S A C T I O N I N B A C K G R O U N D M O D E
CALL TRANSACTION 'IB01' USING
lt_bdcdata[]
MODE lv_mode
MESSAGES INTO lt_messtab[].
* H A N D L E B D C E R R O R S
PERFORM fill_error USING uv_idoc_contrl_docnum
lt_messtab[]
* CHANGING lt_idoc_status[]. "GSK20060915d
CHANGING ct_idoc_status[]. "GSK20060915i
ENDLOOP. "LOOP AT ut_e1stzum INTO ls_e1stzum.
ENDFORM. " create_bom
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form bdc_dynpro
*&---------------------------------------------------------------------*
* The form poupulates the BDCDATA table for the dynpro.
*----------------------------------------------------------------------*
FORM bdc_dynpro USING value(uv_program) TYPE bdcdata-program
value(uv_dynpro) TYPE bdcdata-dynpro
CHANGING ct_bdcdata TYPE tt_bdcdata.
ENDFORM. " bdc_dynpro
*&---------------------------------------------------------------------*
*& Form bdc_field
*&---------------------------------------------------------------------*
* The form populates the table BDCDATA for the screen fields and value
*----------------------------------------------------------------------*
FORM bdc_field USING value(uv_fnam) TYPE bdcdata-fnam
value(uv_fval) TYPE c
CHANGING ct_bdcdata TYPE tt_bdcdata.
DATA : ls_bdcdata TYPE bdcdata. "BDC STRUCTURE
CLEAR ls_bdcdata.
IF NOT uv_fval IS INITIAL.
ls_bdcdata-fnam = uv_fnam.
ls_bdcdata-fval = uv_fval.
APPEND ls_bdcdata TO ct_bdcdata.
ENDIF.
ENDFORM.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.