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

Code modification to read fixed vendor (Urgent)

Former Member
0 Likes
1,028

Hi All,

The below code is basically selecting the fixed vendor as per EORD table for a given material - plant combination. But the issue is for this combination, there can be different fixed vendors but during different times

eg:

Mtl - A, Plant - 1000

Fixed vendor: Vendor1, From 1.1.2000 To 31.12.2003

Fixed vendor: Vendor2, From 1.1.2004 To 31.12.2007

Fixed vendor: Vendor3, From 1.1.2008 To 31.12.2010

So i want to add one more condition, which reads the system date & if the system date lies in-between 1.1.2000 to 31.12.2003, it selects vendor 1 or if the system date lies in between 1.1.2004 to 31.12.2007, then select vendor 2.

So how can i add this condition? The valid from field is EORD-VDATU & the valid to field is EORD-BDATU

Code:

CLEAR: Y_LIFNR, Y_FLIFN, WL_MATNR.

SELECT SINGLE LIFNR FLIFN MATNR FROM EORD INTO (Y_LIFNR, Y_FLIFN,

WL_MATNR)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '.

Hope my question is clear, await inputs

Vivek

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
890

Hello Vivek,

WL_MATNR)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '

AND VDATU LE SYST-DATUM

AND BDATU GE SYST-DATUM.

Regards,

John.

Hi All,

The below code is basically selecting the fixed vendor as per EORD table for a given material - plant combination. But the issue is for this combination, there can be different fixed vendors but during different times

eg:

Mtl - A, Plant - 1000

Fixed vendor: Vendor1, From 1.1.2000 To 31.12.2003

Fixed vendor: Vendor2, From 1.1.2004 To 31.12.2007

Fixed vendor: Vendor3, From 1.1.2008 To 31.12.2010

So i want to add one more condition, which reads the system date & if the system date lies in-between 1.1.2000 to 31.12.2003, it selects vendor 1 or if the system date lies in between 1.1.2004 to 31.12.2007, then select vendor 2.

So how can i add this condition? The valid from field is EORD-VDATU & the valid to field is EORD-BDATU

Code:

CLEAR: Y_LIFNR, Y_FLIFN, WL_MATNR.

SELECT SINGLE LIFNR FLIFN MATNR FROM EORD INTO (Y_LIFNR, Y_FLIFN,

WL_MATNR)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '.

Hope my question is clear, await inputs

Vivek

5 REPLIES 5
Read only

Former Member
0 Likes
891

Hello Vivek,

WL_MATNR)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '

AND VDATU LE SYST-DATUM

AND BDATU GE SYST-DATUM.

Regards,

John.

Read only

0 Likes
890

Mr. John,

Thank you very much for that simple solution. Thanks to the rest for providing different alternatives. Keep the good work going.

Regards,

Vivek

Read only

former_member156446
Active Contributor
0 Likes
890

hi Vivek looks like it cant be done in one select

SELECT SINGLE LIFNR FLIFN MATNR VDATU BDATU

FROM EORD INTO (Y_LIFNR, Y_FLIFN,

WL_MATNR , y _VDATU , y _BDATU)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '.

if sy-datum ge y _VDATU and sy-datum LE y _BDATU.

select single vendor where dates are eq to ur y_*'s

endif.

same with other conditions as well.

hope this works.. award points if useful

Read only

Former Member
0 Likes
890

Hi,

Check the below logic:

if sy-datum >= 1.1.2000 and sy-datum <= 31.12.2003.

vendor = vendor1.

elseif sy-datum >= 1.1.2004 and sy-datum <= 31.12.2007.

vendor = vendor2.

elseif sy-datum >= 1.1.2008 and sy-datum <= 31.12.2010.

vendor = vendor3.

endif.

CLEAR: Y_LIFNR, Y_FLIFN, WL_MATNR.

SELECT SINGLE LIFNR FLIFN MATNR FROM EORD INTO (Y_LIFNR, Y_FLIFN,

WL_MATNR)

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '.

and lifnr = vendor

AND VDATU >= SY-DATUM

AND BDATU <= sy-datum .

Read only

Former Member
0 Likes
890

data: begin of it_mara occurs 0,

LIFNR TYPE LIFNR,

FLIFN TYPE FLIFN,

MATNR TYPE MATNR,

VDATU TYPE sy-datum,

bdatu type sy-datum,

end of it_mara.

SELECT LIFNR

FLIFN

MATNR

VDATU

BDATU

FROM EORD

into corresponding field of table it_mara

WHERE MATNR EQ MARC-MATNR

AND WERKS EQ MARC-WERKS

AND FLIFN NE ' '.

DELETE it_mara

where vdatu < sy-datum

and bdatu > sy-datum.