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

select field from CAUFVD

Former Member
0 Likes
1,626

Hi All ,

I want tp put a logic in the below program. In the below code I have used “ menge “ in mseg table for ‘Work in progress ‘ . But now I want to use the structure CAUFVD-GAMNG for the calculation .

It’s like WIP[Work in progress ] = ( CAUFVD-GAMNG ) - ( CAUFVD-GWEMG ).

Please tell how I will have my approach to the below code. One more thing When I am debugging the below code it’s telling me that there is an error in TAB_ROPFILE-DISPO in r_dispo. Means we can’t use the command while using the select for all entries . Please guide me in this issue.

loop at i_tab.

if i_tab -dispo in r_dispo.

move-corresponding i_tab to i_tab 1.

append i_tab 1.

clear i_tab 1.

endif.

endloop.

if not i_tab [] is initial.

select menge matnr aufnr from mseg

into corresponding fields of table i_workip

for all entries in TAB_ROPFILE

where aufnr = i_tab -PONUM

and matnr = i_tab -MATNR

and bwart = C_MT.

and i_tab -DISPO in r_dispo.

sort i_workip by aufnr matnr menge.

loop at i_workip.

move-corresponding i_workip to wa_workip.

at end of matnr.

sum.

wa_workip-menge = i_workip-menge.

move-corresponding wa_workip to i_wip.

append i_wip.

clear i_wip.

endat.

endloop.

endif.

LOOP AT i_tab.

Read table i_wip

with key aufnr = i_tab -PONUM

matnr = i_tab -matnr binary search.

if sy-subrc eq 0.

i_tab -WIPmenge = i_tab -psmng - i_wip-menge.

modify i_tab transporting wipmenge hsdat.

Regards

Sabya

Hi All ,

I want tp put a logic in the below program. In the below code I have used “ menge “ in mseg table for ‘Work in progress ‘ . But now I want to use the structure CAUFVD-GAMNG for the calculation .

It’s like WIP[Work in progress ] = ( CAUFVD-GAMNG ) - ( CAUFVD-GWEMG ).

Please tell how I will have my approach to the below code. One more thing When I am debugging the below code it’s telling me that there is an error in TAB_ROPFILE-DISPO in r_dispo. Means we can’t use the command while using the select for all entries . Please guide me in this issue.

loop at i_tab.

if i_tab -dispo in r_dispo.

move-corresponding i_tab to i_tab 1.

append i_tab 1.

clear i_tab 1.

endif.

endloop.

if not i_tab [] is initial.

select menge matnr aufnr from mseg

into corresponding fields of table i_workip

for all entries in TAB_ROPFILE

where aufnr = i_tab -PONUM

and matnr = i_tab -MATNR

and bwart = C_MT.

and i_tab -DISPO in r_dispo.

sort i_workip by aufnr matnr menge.

loop at i_workip.

move-corresponding i_workip to wa_workip.

at end of matnr.

sum.

wa_workip-menge = i_workip-menge.

move-corresponding wa_workip to i_wip.

append i_wip.

clear i_wip.

endat.

endloop.

endif.

LOOP AT i_tab.

Read table i_wip

with key aufnr = i_tab -PONUM

matnr = i_tab -matnr binary search.

if sy-subrc eq 0.

i_tab -WIPmenge = i_tab -psmng - i_wip-menge.

modify i_tab transporting wipmenge hsdat.

Regards

Sabya

2 REPLIES 2
Read only

Former Member
0 Likes
1,050

Sabyasachi ,

WIll give comments aginst each changes. If you feel helpful reward points.

  • You can use Where conditionin loop instead of IF statement.

*Even Better will be Move all the table value into another internal table and delete

*ot in ranges.

----


i_tab1[] = i_tab[].

Delete i_itab1 where dispo not in r_dispo .

  • This is will have better Performance than other logic.

----


loop at i_tab.

if i_tab -dispo in r_dispo.

move-corresponding i_tab to i_tab 1.

append i_tab 1.

clear i_tab 1.

endif.

endloop.

----


  • Change the Order fields you used in select Query

----


select menge matnr aufnr from mseg

into corresponding fields of table i_workip

for all entries in i_tab

where aufnr = i_tab -PONUM

and matnr = i_tab -MATNR

and bwart = C_MT.

and DISPO in r_dispo. " and dispo = i_tab-dispo.

  • Either you can use the Range OR For all entries table entry.

----


if not i_tab [] is initial.

select menge matnr aufnr from mseg

into corresponding fields of table i_workip

for all entries in TAB_ROPFILE

where aufnr = i_tab -PONUM

and matnr = i_tab -MATNR

and bwart = C_MT.

and i_tab -DISPO in r_dispo.

----


  • Always sort the internal table with key before you read with Binary Serach

----


sort i_workip by aufnr matnr menge.

loop at i_workip.

move-corresponding i_workip to wa_workip.

at end of matnr.

sum.

wa_workip-menge = i_workip-menge.

move-corresponding wa_workip to i_wip.

append i_wip.

clear i_wip.

endat.

endloop.

endif.

LOOP AT i_tab.

Read table i_wip

with key aufnr = i_tab -PONUM

matnr = i_tab -matnr binary search.

if sy-subrc eq 0.

i_tab -WIPmenge = i_tab -psmng - i_wip-menge.

modify i_tab transporting wipmenge hsdat.

Read only

Former Member
0 Likes
1,050

The logic you wrote is CORRECT...

Follow the same...