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

BDC problem

Former Member
0 Likes
357

Hi all,

I am using the following program to update the BOMs.

The program works fine and updates the BOMs if the components for a particular material are 10 or less

If they are more than that the result is still the 'BOM updated successfully' whereas when I go check in CS02 only the ten componenets are changed and the rest are not changed.

Can anyone suggest me what to do?

Thanks

Sandeep

report zbom_update

no standard page heading line-size 255.

tables: mard.

  • Internal table declarations

data: it_bdcdata like bdcdata occurs 0 with header line.

data: begin of it_bom occurs 0,

matnr like rc29n-matnr,

werks like rc29n-werks,

stlan like rc29n-stlan,

end of it_bom.

data: begin of it_tab occurs 0,

matnr like mast-matnr,

stlal like mast-stlal,

idnrk like stpo-idnrk,

menge(16),

meins(4),

end of it_tab.

data: begin of it_stb occurs 0.

include structure stpox.

data: end of it_stb.

  • Variables declaration

data: v_count(3) type n value '01',

v_count1(3) type c,

v_string type string.

  • Perform to open the input file

perform file_open.

  • Perform to read the data from input file

perform read_dataset.

  • * Perform to close the opened input file

perform file_close.

delete adjacent duplicates from it_tab comparing matnr stlal.

include bdcrecx1.

  • Selection Screen

selection-screen begin of block b1 with frame title text-100.

parameters: p_infile type rlgrap-filename default '/tmp/bom_extract'.

selection-screen end of block b1.

start-of-selection.

perform open_group.

loop at it_tab.

clear it_stb.

refresh it_stb.

call function 'CS_BOM_EXPL_MAT_V2'

exporting

aufsw = 'X'

aumgb = 'X'

capid = ' '

mdmps = 'X'

datuv = sy-datum

mbwls = 'X'

mktls = 'X'

mtnrv = it_tab-matnr

  • mehrs = 'X'

mehrs = ' '

stlal = it_tab-stlal

stlan = '3'

werks = '1353'

mdnot = 'X'

tables

stb = it_stb

exceptions

alt_not_found = 1

call_invalid = 2

material_not_found = 3

missing_authorization = 4

no_bom_found = 5

no_plant_data = 6

no_suitable_bom_found = 7

others = 8.

if sy-subrc <> 0.

  • message id sy-msgid type sy-msgty number sy-msgno

  • with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • Count the number of components for a BOM

describe table it_stb lines v_count1.

refresh it_bdcdata.

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'

it_tab-matnr.

perform bdc_field using 'RC29N-WERKS'

'1353'.

perform bdc_field using 'RC29N-STLAN'

'3'.

perform bdc_field using 'RC29N-STLAl'

it_tab-stlal.

loop at it_stb where stlal = it_tab-stlal.

perform bdc_dynpro using 'SAPLCSDI' '0150'.

concatenate 'RC29P-AUSKZ' '(' v_count ')' into v_string.

perform bdc_field using 'BDC_CURSOR'

v_string.

*perform bdc_field using 'BDC_CURSOR'

  • 'RC29P-AUSKZ(01)'.

perform bdc_field using 'BDC_OKCODE'

'=PALL'.

*perform bdc_field using 'RC29P-AUSKZ(01)'

  • 'X'.

clear v_string.

concatenate 'RC29P-AUSKZ' '(' v_count ')' into v_string.

perform bdc_field using v_string

'X'.

perform bdc_dynpro using 'SAPLCSDI' '2130'.

perform bdc_field using 'BDC_OKCODE'

'=PDAT'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSNR'.

perform bdc_dynpro using 'SAPLCSDI' '2130'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-PRVBE'.

perform bdc_field using 'RC29P-LGORT'

'7001'.

perform bdc_field using 'RC29P-PRVBE'

'REPACK'.

v_count = v_count + 1.

if v_count eq '006'.

perform bdc_dynpro using 'SAPLCSDI' '0150'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

v_count = '001'.

endif.

endloop.

perform bdc_dynpro using 'SAPLCSDI' '0150'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=FCBU'.

perform bdc_transaction using 'CS02'.

endloop.

perform close_group.

----


  • Form file_open

----


  • Form to open the input file

----


form file_open .

open dataset p_infile for input in text mode encoding default.

if sy-subrc <> 0.

message 'Error in opening the file' type 'E'.

endif.

endform. " file_open

----


  • Form read_dataset

----


  • Form to transfer the data from input file to the internal table

----


form read_dataset .

do.

read dataset p_infile into it_tab.

if sy-subrc <> 0.

exit.

endif.

append it_tab.

clear it_tab.

enddo.

endform. " read_dataset

----


  • Form file_close

----


  • Form to close the input file

----


form file_close .

close dataset p_infile.

endform. " file_close

1 REPLY 1
Read only

Former Member
0 Likes
295

Hi ,

When you are calling the perform bdc_transaction and within that there you will have a call transaction modify that call transaction as in following example marked in bold.

DATA class_name(30) TYPE c VALUE 'CL_SPFLI_PERSISTENT'.

DATA: bdcdata_wa TYPE bdcdata,

bdcdata_tab TYPE TABLE OF bdcdata.

DATA opt TYPE ctu_params.

CLEAR bdcdata_wa.

bdcdata_wa-program = 'SAPLSEOD'.

bdcdata_wa-dynpro = '1000'.

bdcdata_wa-dynbegin = 'X'.

APPEND bdcdata_wa TO bdcdata_tab.

CLEAR bdcdata_wa.

bdcdata_wa-fnam = 'BDC_CURSOR'.

bdcdata_wa-fval = 'SEOCLASS-CLSNAME'.

APPEND bdcdata_wa TO bdcdata_tab.

CLEAR bdcdata_wa.

bdcdata_wa-fnam = 'SEOCLASS-CLSNAME'.

bdcdata_wa-fval = class_name.

APPEND bdcdata_wa TO bdcdata_tab.

CLEAR bdcdata_wa.

bdcdata_wa-fnam = 'BDC_OKCODE'.

bdcdata_wa-fval = '=CIDI'.

APPEND bdcdata_wa TO bdcdata_tab.

<b>opt-dismode = 'E'.

opt-defsize = 'X'.

CALL TRANSACTION 'SE24' USING bdcdata_tab OPTIONS FROM opt.</b>

Please reward if useful.