‎2006 Jan 05 6:24 AM
Hi all, i wanna know your thoughts on this. I've been asked to rewrite a few lines of codes, as follows:
CLEAR CUST.
CUST = KUWEV-KUNNR.
IF LIKP-TRAID EQ SPACE.
IF CUST = '1000000001' OR CUST = '1000000002' OR CUST = '1000000004'
OR CUST = '1000000005' OR CUST = '1000000006' OR CUST = '1000000007'
OR CUST = '1000000012' OR CUST = '1000000026' OR CUST = '1000000040'
OR CUST = '1000000041' OR CUST = '1000000042' OR CUST = '1000000050'
OR CUST = '1000000051' OR CUST = '1000000053' OR CUST = '1000000054'
OR CUST = '1000000067' OR CUST = '1000000075' OR CUST = '1000000080'
OR CUST = '1000000092' OR CUST = '1000000128'
OR CUST = '1000000220' OR CUST = '1000000240'
* OR CUST = '1000000474'
OR CUST = '1000000363' OR CUST = '1000000366' OR CUST = '1000000463'
OR CUST = '1000000486' OR CUST = '1000000528' OR CUST = '1000000566'
OR CUST = '1000000580' OR CUST = '1000000641' OR CUST = '1000000643'
OR CUST = '1000000665' OR CUST = '1000000705' OR CUST = '1000000752'
OR CUST = '1000000765' OR CUST = '1000000771' OR CUST = '1000000775'
OR CUST = '1000000777' OR CUST = '1000000785' OR CUST = '1000000808'
OR CUST = '1000000835' OR CUST = '1000000840' OR CUST = '1000000847'
OR CUST = '1000000897' OR CUST = '1000000905' OR CUST = '1000000920'
OR CUST = '1000000925' OR CUST = '1000000935' OR CUST = '1000000960'
OR CUST = '1000001071' OR CUST = '1000001105' OR CUST = '1000001120'
OR CUST = '1000001147' OR CUST = '1000001150' OR CUST = '1000001161'
OR CUST = '1000001185' OR CUST = '1000001289' OR CUST = '1000001397'
OR CUST = '1000001436' OR CUST = '1000001459' OR CUST = '1000001532'
OR CUST = '1000001649' OR CUST = '1000001666' OR CUST = '1000001671'.
* OR CUST = '1000000030'.
MESSAGE i000(z00) WITH 'You must enter pallet quantity'
'for customer ' CUST.
LEAVE TO SCREEN 2000.
ENDIF.
ENDIF.
Since that we no longer want to hard-code the Vendor No., I've been asked to write a new logic. In short, if the user keys in a vendor number that is in the new table (ZZPLT_CUST) i just created, i need to automatically output the message. This is what i've been thinking to write:
TABLES: ZZPLT_CUST.
DATA: VEND LIKE ZZPLT_CUST-KUNNR.
CLEAR CUST.
CUST = KUWEV-KUNNR.
CLEAR VEND.
VEND = ZZPLT_CUST-KUNNR.
IF LIKP-TRAID EQ SPACE.
IF CUST = VEND.
MESSAGE i000(z00) WITH 'You must enter pallet quantity'
'for customer ' CUST.
LEAVE TO SCREEN 2000.
ENDIF.
ENDIF.
Just wanna know your thoughts on it
‎2006 Jan 05 6:46 AM
TABLES: ZZPLT_CUST.
DATA: VEND LIKE ZZPLT_CUST-KUNNR.
CLEAR CUST.
CUST = KUWEV-KUNNR.
CLEAR VEND.
VEND = ZZPLT_CUST-KUNNR.
IF LIKP-TRAID EQ SPACE.
IF CUST = VEND.
MESSAGE i000(z00) WITH 'You must enter pallet quantity' 'for customer ' CUST.
LEAVE TO SCREEN 2000.
ENDIF.
this is fine for any vendor, is it ok....
but what if the other vendors which are not there in your previous if logic...then also will it work..
thanks
vijay
ENDIF.
‎2006 Jan 05 6:45 AM
Bernard,
Just one point here. the VEND that you want to compare with is actually a Z table entry and have about >40 types of VEND in it. So when you are comparing the CUST = VENd, you sould actually b e looping throught the entire list of Z table entries one by one to see, if the CUST exists.
The best way to do it is to do a single select on ypur Ztable where VEND = CUST. If sy-subrc = 0, then entry exists and you should procced with thre LEAVE screen statement.
Shobana
‎2006 Jan 05 6:50 AM
You need to just do this
select * from ZZPLT_CUST
where VEND = CUST.
IF sy-subrc = 0 and traid = space.
Message
Endif.
Im assuming that VEND is the field in your ZZPKT_CUST table which stores all the vendor numbers there.
‎2006 Jan 05 7:03 AM
The table ZZPLT_CUST which i just created has the following fields, length and their respective description:
MANDT(3) -> Client
IND(1) -> Special Indicator
KUNNR(10) -> Customer Number 1
In the original logic, CUST was defined like this:
DATA: CUST LIKE KUWEV-KUNNR.
So i don't think i could just do a SELECT * WHERE VEND = CUST
‎2006 Jan 05 7:08 AM
What doe syour special indicator do? any significance. Still if you just need to compare that your KUWEV-KUNNR which is 10 char against all the entries in ZZPLT_CUST-KUNNR(10 cahr ship to party),
You can do the same select.
SELECT KUNNR up to 1 rows from ZZPT_CUST
into V_KUNNR
where KUNNR = CUST
ENDSELECT,
IF sy-subrc = 0 and LIKP-TRAID = SPACE
perform logic
ENDIF.
‎2006 Jan 05 7:17 AM
The special indicator works similarly like a mark for deletion indicator
‎2006 Jan 05 7:22 AM
Is it an indicator to show that you need not check that particular vendor in the table?
Your requirement is pretty simple, you just need to query your Ztable with the user input in the where caluse. If you need to check only those records that have splind <> X than add that also to the where clause and in this case you can also make it select single as you will be using all the keys.
Hope this helps,
‎2006 Jan 05 7:36 AM
thanks....actually all i wanted to know of any logic that could replace the earlier logic (which can perform the same thing as the earlier one and hopefully provide better performance, since we no longer want to hard-code each and every new vendor number)...for the meanwhile, i'll have to wait for the user to get back to me on this once they've tested it...i won't close this thread yet...
truth to be told, i'm not so sure as to why the indicator is needed inside the table...the consultant wanted it
‎2006 Jan 05 6:46 AM
TABLES: ZZPLT_CUST.
DATA: VEND LIKE ZZPLT_CUST-KUNNR.
CLEAR CUST.
CUST = KUWEV-KUNNR.
CLEAR VEND.
VEND = ZZPLT_CUST-KUNNR.
IF LIKP-TRAID EQ SPACE.
IF CUST = VEND.
MESSAGE i000(z00) WITH 'You must enter pallet quantity' 'for customer ' CUST.
LEAVE TO SCREEN 2000.
ENDIF.
this is fine for any vendor, is it ok....
but what if the other vendors which are not there in your previous if logic...then also will it work..
thanks
vijay
ENDIF.
‎2006 Jan 05 6:59 AM
if '1000000001' and so on are vendor numbers & you are populating them in the table ZZPLT_CUST..
then you can change the logic as below.
CLEAR CUST.
CUST = KUWEV-KUNNR.
IF LIKP-TRAID EQ SPACE.
SELECT SINGLE VENDOR
INTO V_VENDOR
FROM ZZPLT_CUST
WHERE VENDOR = CUST.
IF SY-SUBRC = 0 .
*--CUST = VEND.
MESSAGE i000(z00) WITH 'You must enter pallet
quantity' 'for customer ' CUST.
LEAVE TO SCREEN 2000.
ENDIF.
ENDIF.
Regards,
srikanth