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

va02

Former Member
0 Likes
875

hello everyone,

I written one code below.........but im not sure this one is correct,......anyone can send me the sample programs done with alternatives BOM's..

my probleme here is i cant get the value of stlal in va01....where i got it in mv45afzb and imported to here in mv45afzz.....see my following code...and suggest me or give me some idea's...how can i resolve this problem...

data : begin of it_fg_xvbap occurs 0.

include structure xvbap.

data : end of it_fg_xvbap.

data : begin of it_fg_xvbep occurs 0.

include structure xvbep.

data : end of it_fg_xvbep.

data: begin of it_zfreegoods occurs 0.

include structure zfreegoods.

data: end of it_zfreegoods.

data: v_lines(3) type c,

v_stas(3) type c,

it_fg_index like sy-tabix.

data: v_mitem1_qty like vbap-kwmeng,

v_quantity like zfreegoods-quantity,

v_newqty like zfreegoods-quantity,

v_memid like indx-srtfd VALUE 'ZZBOM'.

IMPORT cstmat FROM MEMORY ID v_memid .

if not xvbap[] is initial.

loop at xvbap where stlal = ' '.

xvbap-stlal = cstmat-stlal.

modify xvbap.

endloop.

endif.

If sy-tcode = 'VA01' or sy-tcode = 'VA02'.

it_fg_xvbap[] = xvbap[].

if not it_fg_xvbap[] is initial.

read table it_fg_xvbap index 1.

select * from zfreegoods into table it_zfreegoods

for all entries in it_fg_xvbap

where matnr eq it_fg_xvbap-matnr.

  • Check if the BOM is completely exploded for mix-match.

if not it_zfreegoods[] is initial.

loop at it_fg_xvbap.

  • If user selects Alternative BOM '04' MIX and MATCH concept with

  • quantity combinations 2-1,2-2,3-3,4-2 and 5-1.

if it_fg_xvbap-stlal = '04'.

read table it_zfreegoods with key matnr = it_fg_xvbap-matnr.

if sy-subrc eq 0.

  • This scenario triggers - min qty 2

if it_fg_xvbap-kwmeng <= '1.000'.

it_fg_xvbap-kwmeng = '2.000'.

it_fg_xvbap-lsmeng = it_fg_xvbap-kwmeng.

endif.

  • This scenario triggers - max qty 5

if it_fg_xvbap-kwmeng >= '6.000'.

message s021(zsnd) with '6'.

it_fg_xvbap-kwmeng = '5.000'.

it_fg_xvbap-lsmeng = it_fg_xvbap-kwmeng.

endif.

v_mitem1_qty = it_fg_xvbap-kwmeng.

v_quantity = it_zfreegoods-quantity.

modify it_fg_xvbap.

clear v_lines.

continue.

endif.

if it_zfreegoods-matnr ne it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

it_fg_xvbap-lsmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

v_lines = v_lines + 1.

if it_zfreegoods-zfreemodel eq it_fg_xvbap-matnr.

if v_mitem1_qty <= v_quantity.

v_newqty = v_quantity - v_mitem1_qty.

it_fg_xvbap-kwmeng = v_newqty.

it_fg_xvbap-lsmeng = v_newqty.

modify it_fg_xvbap.

else.

if fcode eq 'SICH'.

message e020(zsnd) with it_zfreegoods-quantity .

else.

message s020(zsnd) with it_zfreegoods-quantity .

endif.

endif.

endif.

endif. " it_fg_xvbap-stlal '04'

  • If user selects Alternative BOM '03'.

if it_fg_xvbap-stlal = '03'.

read table it_zfreegoods with key matnr = it_fg_xvbap-matnr.

if it_zfreegoods-matnr ne it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

it_fg_xvbap-lsmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

if it_zfreegoods-zfreemodel eq it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

it_fg_xvbap-lsmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

endif. " it_fg_xvbap-stlal '03'

  • If user selects Alternative BOM '02'.

if it_fg_xvbap-stlal = '02'.

read table it_zfreegoods with key matnr = it_fg_xvbap-matnr.

if it_zfreegoods-matnr ne it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

it_fg_xvbap-lsmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

endif. " it_fg_xvbap-stlal '02'

  • If user selects Alternative BOM '01'.

if it_fg_xvbap-stlal = '01'.

read table it_zfreegoods with key matnr = it_fg_xvbap-matnr.

if it_zfreegoods-matnr ne it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

it_fg_xvbap-lsmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

endif. " it_fg_xvbap-stlal '01'

endloop.

if not xvbep[] is initial.

it_fg_xvbep[] = xvbep[].

loop at it_fg_xvbep.

clear it_fg_xvbap.

read table it_fg_xvbap with key posnr = it_fg_xvbep-posnr.

if sy-subrc eq 0.

it_fg_index = sy-tabix.

it_fg_xvbep-wmeng = it_fg_xvbap-kwmeng.

it_fg_xvbep-bmeng = it_fg_xvbap-kwmeng.

it_fg_xvbep-lmeng = it_fg_xvbap-kwmeng.

it_fg_xvbep-cmeng = it_fg_xvbap-kwmeng.

modify it_fg_xvbep index it_fg_index.

endif.

endloop.

xvbep[] = it_fg_xvbep[].

endif.

xvbap[] = it_fg_xvbap[].

endif. " it_zfreegoods table

endif.

free memory id v_memid.

endif. "end if va01 and va02.

thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
797

Can you please explain more about the functionality of the report and what exactly you wanted to do, may be business process behind the report.

Regards,

Amey

Read only

0 Likes
797

HI AMREY,

my requirement is BOM When I am creating sales order. everything is fine I configured the material in CSO1 what I want......here actual requirement is ...there is 4 types of BOM's. if the user selects these 4 BOM's ....

BOM1- material1 with mat-Item1 with same quantity

BOM2- material1 with mat-Item1, mat-Item2, mat-Item3 with different quantity

BOM3- material1 with mat-Item1, mat-Item2, mat-Item3 and material2 with some quantity.

BOM4- material1 with mat-Item1, mat-Item2, mat-Item3 and material2 with MIX and Match quantity(material1 and material2 combination is 6 units.) If i give material1 with 2 quantity the material2 should be he quantity 4.

I wrote the above code but still it like a hardcodeing ....so please send me the corrections or give me any other code how to write.

Thanks in advance.

Read only

Former Member
0 Likes
797

You are importing from memory, where are you exporting it? Probably there is nothing in this import.

IMPORT cstmat FROM MEMORY ID v_memid .

Read only

0 Likes
797

Hello srinivas,

I am exporting it from MV45AFZB.

thanks,

Message was edited by:

madhu vishwanath

Read only

Former Member
0 Likes
797

Hi,

Please try this.


In program MV45AFZB.


...
data: v_stlal1 like cstmat-stlal.
 
v_stlal1 = cstmat-stlal.
export v_statl1 to memory id 'STLAL'.
... 





In program MV45AFZZ. 


...
data: v_stlal2 like cstmat-stlal.
 
import v_stlal2 from memory id 'STLAL'.

if not xvbap[] is initial.
  loop at xvbap where stlal = ' '.
    xvbap-stlal = v_stlal2.
    modify xvbap.
  endloop.

...

Regards,

Ferry Lianto

Read only

0 Likes
797

hi FERRY LIANTO,

I did what exactly u told me........i got the requirement by using it(everything is good..when i did in VA01) once i need to change the document in VA02 then all the stlal entires in xvbap will gone.....because...cstmat-stlal is empty when it is in VA02.....that time(changing document) problem is coming...my code is not working in mv45afzz..........

for this i have another solution.....can u help me how i can do it....

I created a custom table and zfreegoods...its already in the code...so in that if i send values of stlal....by useing that i can write the code write.....can u help me out how can i write the code and all.....

thanks.