*&---------------------------------------------------------------------*
*& 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.
REFRESH : lt_bdcdata,
lt_messtab.
CLEAR ls_z1eqst.
READ TABLE ut_z1eqst INTO ls_z1eqst
WITH KEY psgnum = ls_e1stzum-segnum BINARY SEARCH.
IF sy-subrc NE 0.
CLEAR ls_messtab.
ls_messtab-msgv1 = 'No header segment found'(001).
PERFORM update_idoc_status_325
USING uv_idoc_contrl_docnum
* '53' "GSK20060915d
'51' "GSK20060915i
'E'
ls_messtab-msgid
ls_messtab-msgnr
ls_messtab-msgv1
ls_messtab-msgv2
ls_messtab-msgv3
ls_messtab-msgv4
* CHANGING lt_idoc_status[]. "GSK20060915d
CHANGING ct_idoc_status[]. "GSK20060915i
CONTINUE.
ENDIF.
CLEAR ls_e1stkon.
READ TABLE ut_e1stkon INTO ls_e1stkon
WITH KEY psgnum = ls_e1stzum-segnum BINARY SEARCH.
IF sy-subrc NE 0.
CLEAR ls_messtab.
ls_messtab-msgv1 = 'No header segment found'(001).
PERFORM update_idoc_status_325
USING uv_idoc_contrl_docnum
* '53' "GSK20060915d
'51' "GSK20060915i
'E'
ls_messtab-msgid
ls_messtab-msgnr
ls_messtab-msgv1
ls_messtab-msgv2
ls_messtab-msgv3
ls_messtab-msgv4
* CHANGING lt_idoc_status[]. "GSK20060915d
CHANGING ct_idoc_status[]. "GSK20060915i
CONTINUE.
ENDIF.
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.
DATA : ls_bdcdata TYPE bdcdata. "BDC STRUCTURE
CLEAR ls_bdcdata.
ls_bdcdata-program = uv_program.
ls_bdcdata-dynpro = uv_dynpro.
ls_bdcdata-dynbegin = 'X'.
APPEND ls_bdcdata TO ct_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.
ALSO READ:
- BDC For Open Sales Order - SD (VA01).
- BDC Program To Upload Material Master Data (MM01).
- BDC Program For Vendor XK01.
- BDC Program To Send Mails And Trigger Jobs.
- BDC Program To Load The Material Assignment Of Routing (CA02) - PP.
I like the helpful info you provide in your articles.
ReplyDeleteI will bookmark your blog and check again here regularly.
I am quite certain I'll learn many new stuff right here! Best of luck for the next!
Feel free to surf to my web-site ... dvd recorders for sale
I am sure this piece of writing has touched all the internet visitors, its really really pleasant article on
ReplyDeletebuilding up new webpage.
Here is my page inquiry