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

Question about SAPScript

former_member220801
Participant
0 Likes
756

I need to display 2 fields value in a line, so I add two sysmbol '&field1&' and '&field2'. But '&field1' sometimes needed to suppress in some situation.

I handle it by creating 2 two text element 'Item1' and 'Item2'. Item1 contains only field2 while Item2 contains both. So I check it in my ABAP program, and determine which text element will be used.

Is there any better way to do this?

Can I use 'IF...ENDIF' in this case? How to use it if field1 is a numeric field and suppress when it is zero?

Thanks!

1 ACCEPTED SOLUTION
Read only

former_member186741
Active Contributor
0 Likes
737

i THINK YOU CAN DO:

IF &FIELD1& = 0.

&FIELD2&

ELSE.

&FIELD1& &FIELD2&

ENDIF.

7 REPLIES 7
Read only

Former Member
0 Likes
737

You can use conditional statements in SAPScript:

Visit <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm">SAP Script - Control Commands</a> for more details..

Any other problem please let us know.

Read only

former_member186741
Active Contributor
0 Likes
738

i THINK YOU CAN DO:

IF &FIELD1& = 0.

&FIELD2&

ELSE.

&FIELD1& &FIELD2&

ENDIF.

Read only

0 Likes
737

I am using the graphical form painter.

When I click the insert command icon,

there are sysbols, command, text element, comment, sap characters and link for me to choose?

I have chosen 'Command' and type the following command

IF &FIELD1& <> 0. &FIELD1&. ENDIF.

but there is error....

Read only

0 Likes
737

You have to do multiple commands...line 1 has

IF &FIELD1& <> 0.

line2:

&FIELD1&

line3:

ENDIF.

Read only

0 Likes
737

Hi Neil

I have tried the same it

IF &FIELD1& <> 0.

line2: service tax &FIELD1&

line3: ENDIF.

but still it is not working. if field1 is zero then it is printing service tax 0, i donot want to print any line is field1 is zero. Please help

thanks

Vinayak

Read only

0 Likes
737

Hi Vinayak,

I think this is because the variable has decimal places and sapscript gets confused. Declare a constant in your abap say, c_zero, of the same type as field1 but with a value of 0. Change your sapscript to:

IF &FIELD1& <> &c_zero&.

line2: service tax &FIELD1&

line3: ENDIF.

Read only

0 Likes
737

Yes, I think there is something confused when passing value to SAPScript form.

I have field1 of data type CURR(13,2).

IF &field1& <> 0.

&field1&

ENDIF.

It doesn't work

But

IF &field1& <> ' 0.00'. <- 9 space before 0.00

&field1&

ENDIF.

It works.

Please correct me if I am wrong. Thanks!