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

Printing Variable Conditionally in Smartforms

yogesh_pathak
Participant
0 Likes
2,233

Hello Sir,

I am new to ABAP, and on project doing Purchase Order Form.

Question:

=======

I have Six variables ( Two will be printed in one line in a window ) for Schedule Date and Schedule Quantity.

SDATE1 SQTY1

SDATE2 SQTY2

SDATE3 SQTY3

I want to print it like this, only if date or quantity has a value:

Date: &SDATE1& Qty: &QTY1&

Date: &SDATE2& Qty: &QTY2&

Date: &SDATE3& Qty: &QTY3&

( The word "Date:" and "Qty:" is a Text)

I have tried this:

IF &SDATE1& NE ' ' AND &SQTY1& NE ' '

Date: &sdate1(CZ)& Qty: &sqty1(CZ)&

ENDIF

IF &SDATE2& NE ' ' AND &SQTY2& NE ' '

Date: &sdate2(CZ)& Qty: &sqty2(CZ)&

ENDIF

IF &SDATE3& NE ' ' AND &SQTY3& NE ' '

Date: &sdate1(CZ)& Qty: &sqty1(CZ)&

ENDIF

but the result is:

Date: 07.03.2009 Qty: 5,000.000

Date: Qty:

Date: Qty:

Last two lines not required since it has no value.

Please help me.

Thanks and regards,

Yogesh Pathak

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,724

Hello,

Create 3 different text elemnts and write the conditions in the conditions tab.

I think you have created a single text element & written your code there.

BR,

Suhas

8 REPLIES 8
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,725

Hello,

Create 3 different text elemnts and write the conditions in the conditions tab.

I think you have created a single text element & written your code there.

BR,

Suhas

Read only

0 Likes
1,724

Can you please guide me how to write condition in condition tab, I have'nt done that before.

For you information I have created three different text eleminets and written just variables with no "IF" like this:

(In text element 1)

Date: &SDATE1& Qty: &SQTY1&

(In text element 1)

Date: &SDATE2& Qty: &SQTY2&

(In text element 1)

Date: &SDATE3& Qty: &SQTY3&

But still the output is same.

Edited by: Yogesh Pathak on Jan 22, 2009 6:57 AM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,724

Hello Yogesh,

In each text element you will find a "Conditions" tab.

In this tab, you can give the conditions as you like.

e.g.,


&SDATE1& NENITIAL 
&SQTY1& NE INITIAL
" Click on the pushbutton to get the relation and by default it will be AND operator

BR,

Suhas

Edited by: Suhas Saha on Jan 22, 2009 11:30 AM

Read only

Former Member
0 Likes
1,724

in global declaration declare

flag1, flag2, flag3..

create program lines before the text node ,in that write below code.

IF &SDATE1& NE ' ' AND &SQTY1& NE ' '

flag1 = 'X'.

ENDIF

IF &SDATE2& NE ' ' AND &SQTY2& NE ' '

flag2 = 'X'.

ENDIF

IF &SDATE3& NE ' ' AND &SQTY3& NE ' '

flag3 = 'X'.

ENDIF

in condition tab of (In text element 1)

flag1 = X.

in condition tab of (In text element 2)

flag2 = X.

in condition tab of (In text element 3)

flag3 = X.

Read only

Former Member
0 Likes
1,724

Hi Yogesh,

Better create three text elements for all three lines and place condition in the condition tab. Not in the program lines.

Hope this will work

bye

Read only

Former Member
0 Likes
1,724

when u create ur text elements also put condition on the label text element such that if value is initial then label shud also not be printed.

Read only

Former Member
0 Likes
1,724

the best way is take template and pass the values....

Read only

yogesh_pathak
Participant
0 Likes
1,724

My colleague has come-up with the solution:

Many many thanks to those who have answered.

IN TEMPLATE:

============

Shipping Schedule:

&XDT1& &SDATE1(CZ)& &XQTY1& &SQTY1(CZ)&

&XDT2& &SDATE2(CZ)& &XQTY2& &SQTY2(CZ)&

&XDT3& &SDATE3(CZ)& &XQTY3& &SQTY3(CZ)&

IN PROGRAM LINES:

=================

*loop at IEKET into WEKET.

  • case WEKET-ETENR.

  • when '0001'.

  • SDATE1 = WEKET-EINDT.

  • SQTY1 = WEKET-MENGE.

  • if SQTY1 <> 0.

  • XDT1 = 'Date: '.

  • XQTY1 = 'Qty: '.

  • else.

  • XDT1 = ' '.

  • XQTY1 = ' '.

  • endif.

  • when '0002'.

  • SDATE2 = WEKET-EINDT.

  • SQTY2 = WEKET-MENGE.

  • if SQTY2 <> 0.

  • XDT2 = 'Date: '.

  • XQTY2 = 'Qty: '.

  • else.

  • XDT2 = ' '.

  • XQTY2 = ' '.

  • endif.

  • when '0003'.

  • SDATE3 = WEKET-EINDT.

  • SQTY3 = WEKET-MENGE.

  • if SQTY3 <> 0.

  • XDT3 = 'Date: '.

  • XQTY3 = 'QTY: '.

  • else.

  • XDT3 = ' '.

  • XQTY3 = ' '.

  • endif.

  • endcase.

*endloop.

Thanks Once again.

Regards

Yogesh Pathak