on 09-25-2009 3:08 PM
Hello Experts,
I hope somebody can advice something... Problem is with conditional processing inside of SAPscript.
I need to display line item depending on customer/vendor account number: variable &DKADR-KONTO&, defined as CHAR(10).
It's required to have different line item for accounts 100-999, and different for others. My piece of code:
/: IF &DKADR-KONTO& GE '100' AND &DKADR-KONTO& LE '999'
* &SAPSCRIPT-COUNTER_0(+)&,,&RF130-XBLNR(10)&,,&RF130-BLDAT&
/: ELSE
* &SAPSCRIPT-COUNTER_0(+)&,,&RF130-BELNR(10)&,,&RF130-BLDAT&
/: ENDIF
Can you tell me what is wrong with the condition? I don't know why It fits also for customer greater than 999?! To be honest it drives me crazy... Is it because of CHAR type? How to manage with this?
Thanks in advance and best regards,
Greg
Hi
Yes, you're right
The problem is if you consider 1000 as number, 1000 > 999, but if u consider 1000 as char is smaller than 999, because it starts with 1.
See this little sample:
DATA: V1(10) VALUE '999',
V2(10) VALUE '1000'.
IF V1 > V2.
WRITE: V1, 'greater than', V2.
ENDIF.
U should move the account code (but if it's always a number) in a new variable type N of 10 char and use it for the control.
Other solution can be to consider the real code of the account:
in the sapscript u see 100 and 999, because the field HKONT uses the convertion routine ALPHA in order to delete the leading zero.
That means the account codes really are 0000000100, 0000000999. So my sample becames:
DATA: V1(10) VALUE '0000000999',
V2(10) VALUE '0000001000'.
IF V2 > V1.
WRITE: V2, 'greater than', V1.
ENDIF.
Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Max,
Thanks, that is what I supposed. Problem is that program for my sapscript it's SAP standard and I have no influence for type of data provided.
My the only idea so far is to perform this check by procedure in some external ABAP program but would be great to have solution only inside of the sapscript.
Best regards,
Greg
Hi,
If somebody is interested, I think I've found the solution - just checking if KONTO (as CHAR) has at least 3 characters and not more than 3. Works so far.
/: IF &DKADR-KONTO+3(1)& EQ '' AND &DKADR-KONTO+2(1)& NE ''
* &SAPSCRIPT-COUNTER_0(+)&,,&RF130-XBLNR(10)&,,&RF130-BLDAT&
/: ELSE
* &SAPSCRIPT-COUNTER_0(+)&,,&RF130-BELNR(10)&,,&RF130-BLDAT&
/: ENDIF
Regards,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.