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

SAP Script : conditions

Former Member
0 Likes
732

Dear All,

I am working on SAP Script.

I have to print so

<b>invoice Number Doc type invoice date .....</b>

so I have used &bseg-belnr&,,XXXXX,,&BSID-BLDAT&

Now my question is in what should I enter in XXXXX place.

Actually there is a condiation there.

if bseg-bschl = 01 then INV,

if bseg-bschl = 04 then DED

if bseg-bschl = 06 then DED

if bseg-bschl = 11 then CR

if bseg-bschl = 15 then PAY

ELSE

ADJ.

At first my Intension was doing So.

if bseg-bschl = 01 then INV

&bseg-belnr&,,INV,,&BSID-BLDAT&

elseif

&bseg-belnr&,,DED,,&BSID-BLDAT&

AND SO ON .......

But I have condition on &BSID-BLDAT& Field also !!....and what if I have conditions on other fields in same row ?

How Should I go ahead .. Please advice me ..

Actually I am trying to use this in SAP SCript Editor only, Should I try in print program.

Please advice me ...

Thanks & Regards

Venkat.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
686

If your conditions are somewhat complex, I usually do this stuff in the print program as opposed to the sapscript editor. Like in your case I would use a variable here. In my print program is where I would do the conditions and fill this variable there. That way all i need in my sapscript editor is this..

&bseg-belnr&,,&VARIALBE&,,&BSID-BLDAT&

Regards,

Rich Heilman

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
687

If your conditions are somewhat complex, I usually do this stuff in the print program as opposed to the sapscript editor. Like in your case I would use a variable here. In my print program is where I would do the conditions and fill this variable there. That way all i need in my sapscript editor is this..

&bseg-belnr&,,&VARIALBE&,,&BSID-BLDAT&

Regards,

Rich Heilman

Read only

0 Likes
686

Hi Rich,

Thanks for quick reply.

with your reply I got other doubt, Can I use a variable in SAP Script Editor only.

I am sorry if this sounds silly,

Thanks & Regards

Venkat

Read only

0 Likes
686

Yes, you can, but then you still have all of that logic cluttering up the form. This is just my opinion, but if you have control over the form and the print program, meaning they are custom, then I always suggest to have your logic separated from the layout. Meaning, put your logic in the print program, leave the sapscript editor for taking care of the layout. Yes, there are some exceptions, and again just my opinion. I think it is easier to read/maintain later.

By the way you use the keyout DEFINE in the sapscript editor.

Regards,

Rich Heilman

Read only

0 Likes
686

Hi,

Check this link , create subroutine in script and do the calculation in report and pass the value to script.

Laxman

Read only

Former Member
0 Likes
686

if &bseg-bschl& = 01 (Condition 1 )

if condition2 = true (condition for BLDAT)

&bseg-belnr&,,INV,,&BSID-BLDAT&

else

&bseg-belnr&,,INV,,

endif.

elseif

&bseg-belnr&,,DED,,&BSID-BLDAT&

SO ON...

Read only

0 Likes
686

Dear Rich and Others,

Thanks for your inputs, I will follow your suggestions and go ahead and work with it.

hopw this is not going to be a big problem. Meanwhile I wil allot points for your time and concern.

Thanks & Regards

Venkat.