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

ABAP GENERAL

Former Member
0 Likes
573

HI,

please help me out with this code.

3.Select Single SPART from MARA into V_SPART where MATNR = ZMATNR.

4. IF BSART = 'ZSTO' and V_SPART = '30'.(bsart should be taken from vbep table)

Select VBELN and POSNR from VBRP into V_VBELN,V_POSNR where matnr= ZMATNR and WERKS = ZWERKS and ERDAT = SY-DATUM.(If there is no record, search for one day earlier(SY-DATUM -1). Repeat this until a record is found for the above combination excluding date)

5. If multiple VBELNs are found for date, Check the prices for each of them as follows:

Select KNUMV from KONV where KNUMV = V_KNUMV and KPOSN = V_POSNR and KSCHL = 'ZSTP'.(Latest Price)

6 . Select the highest KWERT and Copy to XKWERT.(zmatnr ,zwerks,zreswk are select options)

regards,

deepthi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
515

see example bellow.

note that to make it work the way your spec. is asking, the select in VBRP should be done to an internal table, so you can check if there are multiple entries.

Select Single SPART from MARA into V_SPART where MATNR = ZMATNR.

data:

l_date type dats.

l_date = sy-datum + 1.

do while sy-subrc ne 0.

l_date = l_date - 1.

IF BSART = 'ZSTO' and V_SPART = '30'.

Select single VBELN, POSNR

from VBRP

into V_VBELN,V_POSNR

where matnr= ZMATNR

and WERKS = ZWERKS

and ERDAT = l_date.

endif.

enddo.

Message was edited by:

Hermes Felipe Alves

HI,

please help me out with this code.

3.Select Single SPART from MARA into V_SPART where MATNR = ZMATNR.

4. IF BSART = 'ZSTO' and V_SPART = '30'.(bsart should be taken from vbep table)

Select VBELN and POSNR from VBRP into V_VBELN,V_POSNR where matnr= ZMATNR and WERKS = ZWERKS and ERDAT = SY-DATUM.(If there is no record, search for one day earlier(SY-DATUM -1). Repeat this until a record is found for the above combination excluding date)

5. If multiple VBELNs are found for date, Check the prices for each of them as follows:

Select KNUMV from KONV where KNUMV = V_KNUMV and KPOSN = V_POSNR and KSCHL = 'ZSTP'.(Latest Price)

6 . Select the highest KWERT and Copy to XKWERT.(zmatnr ,zwerks,zreswk are select options)

regards,

deepthi

3 REPLIES 3
Read only

Former Member
0 Likes
515

Hi,

What exactly r u looking for? the explanation of the logic or the code for the logic

Regards

KD

Read only

Former Member
0 Likes
515

What are the problems are u facing , what exactly do u want.

Read only

Former Member
0 Likes
516

see example bellow.

note that to make it work the way your spec. is asking, the select in VBRP should be done to an internal table, so you can check if there are multiple entries.

Select Single SPART from MARA into V_SPART where MATNR = ZMATNR.

data:

l_date type dats.

l_date = sy-datum + 1.

do while sy-subrc ne 0.

l_date = l_date - 1.

IF BSART = 'ZSTO' and V_SPART = '30'.

Select single VBELN, POSNR

from VBRP

into V_VBELN,V_POSNR

where matnr= ZMATNR

and WERKS = ZWERKS

and ERDAT = l_date.

endif.

enddo.

Message was edited by:

Hermes Felipe Alves