Skip to Content
0
Former Member
Nov 11, 2010 at 07:04 AM

sales order with material having environmentally rlavant flag checked

25 Views

Hi All,

I have a requirement where i have to develop a ALV for sales order details with material having environmentally rlavant flag checked during material creation.

Problem: The details of sales orders are picked, whic dont have material.

So I have used the following logic:

1) data retrieval:

select vbeln

erdat

auart

kunnr

from vbak

into table it_vbak

where erdat in s_erdat

and auart in s_auart.

if it_vbak is not initial.

select vbeln

matnr

from vbap

into table it_vbap

FOR ALL ENTRIES IN it_vbak

where vbeln = it_vbak-vbeln.

if it_vbap is not initial.

select matnr

kzumw

from mara

into table it_mara

FOR ALL ENTRIES IN it_vbap

WHERE matnr = it_vbap-matnr

and kzumw = 'X'.

endif.

select vbeln

bstkd

from vbkd

into table it_vbkd

FOR ALL ENTRIES IN it_vbak

where vbeln = it_vbak-vbeln.

select vbeln

parvw

kunnr

from vbpa

into table it_vbpa

FOR ALL ENTRIES IN it_vbak

where parvw = 'WE'

and vbeln = it_vbak-vbeln.

endif.

if it_vbpa is not initial.

SELECT kunnr

adrnr

from kna1

into table it_kna1

FOR ALL ENTRIES IN it_vbpa

where kunnr = it_vbpa-kunnr.

if sy-subrc eq 0.

select addrnumber

name1

name2

street

city1

region

post_code1

from adrc

into TABLE it_adrc

FOR ALL ENTRIES IN it_kna1

where addrnumber = it_kna1-adrnr.

if it_adrc is NOT INITIAL.

select addrnumber

smtp_addr

from adr6

into TABLE it_adr6

FOR ALL ENTRIES IN it_kna1

where addrnumber = it_kna1-adrnr.

endif.

endif.

endif.

2) Reading the data:

loop at it_vbak into wa_vbak.

clear wa_final.

read table it_vbap into wa_vbap with key vbeln = wa_vbak-vbeln.

read table it_mara into wa_mara with key matnr = wa_vbap-matnr.

read table it_vbkd into wa_vbkd with key vbeln = wa_vbak-vbeln.

read table it_vbpa into wa_vbpa with key vbeln = wa_vbak-vbeln.

read table it_kna1 into wa_kna1 with key kunnr = wa_vbpa-kunnr.

read table it_adrc into wa_adrc with key addrnumber = wa_kna1-adrnr.

read table it_adr6 into wa_adr6 with key addrnumber = wa_kna1-adrnr.

wa_final-matnr = wa_mara-matnr.

wa_final-bstkd = wa_vbkd-bstkd.

wa_final-erdat = wa_vbak-erdat.

wa_final-kunnr = wa_vbpa-kunnr.

wa_final-name1 = wa_adrc-name1.

wa_final-name2 = wa_adrc-name2.

wa_final-street = wa_adrc-street.

wa_final-city1 = wa_adrc-city1.

wa_final-region = wa_adrc-region.

wa_final-post_code1 = wa_adrc-post_code1.

wa_final-smtp_addr = wa_adr6-smtp_addr.

append wa_final to it_final.

clear wa_final.

endloop.

Problem: The details of sales orders are picked, whic dont have material.

So please suggest me the solution for this problem.

With Regards,

S.Asha.