2009 Jan 09 5:44 AM
Hi,
I have to validate is the vendor given is one time vendor or not.Have written the code as
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE ktokk INTO gw_lfa1 FROM lfa1 WHERE lifnr IN s_lifnr.
IF gw_lfa1 NE 'ZECS'.
MESSAGE e000 WITH 'Specified vendor is not a onetime vendor'.
ENDIF.
ENDIF.
In this type of type if am giving a list of vendors if the first vendor is not reaching the criteria its throwing an error message and coming out.But i need to validate all the vendors and other process should be done for one time vendors alone.Please help me in changing the coding
2009 Jan 09 6:35 AM
Hello Saranya,
I dont understand this point:
i need to validate all the vendors and other process should be done for one time vendors alone
Please clarify, if you want to throw an error message if no ONE TIME vendors are available for the input provided. If so, you can try the code below:
IF NOT s_lifnr[] IS INITIAL.
SELECT lfa1 ktokk
INTO TABLE IT_LFA1
FROM lfa1 WHERE lifnr IN s_lifnr.
IF SY-SUBRC NE 0.
MESSAGE e000 WITH 'No Valid Vendor exists for Input data'.
ELSE.
LOOP AT IT_LFA1 INTO WA_LFA1.
IF WA_LFA1-KTOKK = 'ZECS'.
APPEND WA_LFA1 TO IT_ZECS. "IT_ZECS stores all one-time vendors
CLEAR WA_LFA1.
ENDIF.
ENDLOOP.
ENDIF.
IF IT_ZECS IS INITIAL.
MESSAGE e000 WITH 'No onetime vendor exists for Input data'.
ENDIF.
ENDIF.
Hope this helps.
BR,
Suhas
2009 Jan 09 6:10 AM
Hi,
first select all the Vendors in an internal Table based on S_lifnr.
And then if ktokk NE ZECS delete data from internal Table.
Now you will get data in the table only for one time vendor.
If the internal Table is empty there is not one time vendor.
Regards
Sandipan
Edited by: Sandipan Ghosh on Jan 9, 2009 11:41 AM
2009 Jan 09 6:14 AM
try like this.....
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT ktokk INTO corresponding fields of table it_lfa1 FROM lfa1 WHERE lifnr IN s_lifnr.
loop at it_lfa1.
IF it_lfa1-ktokk NE 'ZECS'.
MESSAGE e000 WITH 'Specified vendor is not a onetime vendor'.
ENDIF.
endloop.
ENDIF.
2009 Jan 09 6:23 AM
Hi,
please get all the entries in a internal table tb_lfa1.
loop throgh the table and check if any one time vendor are there.if u want to continue the process for all the one-time vendors update the selection table s_lifnr by deleting the entries of the lifnr which are not one time vendors or re-create the selection table with correct list of one-time vendors who satisfy ur criteria.
Regards,
Achu
2009 Jan 09 6:35 AM
Hello Saranya,
I dont understand this point:
i need to validate all the vendors and other process should be done for one time vendors alone
Please clarify, if you want to throw an error message if no ONE TIME vendors are available for the input provided. If so, you can try the code below:
IF NOT s_lifnr[] IS INITIAL.
SELECT lfa1 ktokk
INTO TABLE IT_LFA1
FROM lfa1 WHERE lifnr IN s_lifnr.
IF SY-SUBRC NE 0.
MESSAGE e000 WITH 'No Valid Vendor exists for Input data'.
ELSE.
LOOP AT IT_LFA1 INTO WA_LFA1.
IF WA_LFA1-KTOKK = 'ZECS'.
APPEND WA_LFA1 TO IT_ZECS. "IT_ZECS stores all one-time vendors
CLEAR WA_LFA1.
ENDIF.
ENDLOOP.
ENDIF.
IF IT_ZECS IS INITIAL.
MESSAGE e000 WITH 'No onetime vendor exists for Input data'.
ENDIF.
ENDIF.
Hope this helps.
BR,
Suhas