cancel
Showing results for 
Search instead for 
Did you mean: 

IF Condiitions / Sapscript

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

suzy_bijnens
Active Participant
0 Kudos

Hi Gregory,

Just a wild guess: maybe you can check on the amount of digits (without leading zeros of course). Something like strlen(x) = 3?

Hope this helps,

Suzy

Former Member
0 Kudos

Suzy,

I'm not very familiar with printing but I don't think it's possible at the sapscript side.

Regards,

Greg

Answers (1)

Answers (1)

Former Member
0 Kudos

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