cancel
Showing results for 
Search instead for 
Did you mean: 

Printing text depending on condition satisfied

Former Member
0 Kudos

Hi all,

Here I need to print text depending on condition satisfied.print this &GS_IT_GEN-SHORT_TEXT& or print this &gwa_equi-groes& &gwa_equi-herst& &gwa_t370k-eartx&.how to use variable in smartform and print program to print either of the text.if possible provide sample code to achieve this.as i am new to form printing section i don't know much about it's programming.

Thanks in advance.

Regards,

Harshada

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you can define variables in the Global definitions node,

and we can create program lines in the smartform and in that program lines you can write ABAP code,

so, here based on the conditions we can assign. for eg:

l_var1 should be defined in the global definitions node.

if condiion 1.

l_var1 = g_value1.

elseif condition 2.

l_var1 = g_value2

endif.

and then you can print &l_var1&.

Edited by: Radha Vineela Aepuru on Aug 10, 2010 4:10 PM

Former Member
0 Kudos

Hi,

thanks for quick response.here i have defined variable lv_ref type i ,in global definitions.and written code in program lines as follows.

first i am reading data from internal table.

IF SY-SUBRC = 0.

LV_REF = 1.

ELSE.

LV_REF = 0.

ENDIF.

is it necessary to make changes in print program also?

regards,

Harshada

Former Member
0 Kudos

Hi..

Once you have the required data in your smartform, you need not change the Print Program at all. But make sure the internal table you are reading and checking with is populated with values, whether from print program or in smartform itself.

Regards,

Karthik

Former Member
0 Kudos

Hi,

required data is not in the program and smartform.so,need to build logic for that.is it required to pass condition logic in print program also.

regards,

Harshada

Former Member
0 Kudos

Hi..

You need to do this process either in the print program or in the smartform.

If feasible you try to use these conditions and populate these conditions based fields while populating the final internal table that you are passing into the smartform.

Else, in smartform you can do this while reading or looping the internal table.

But its is important that the internal table or whichever is containing the value is passed into the smartform through the interface i.e. the data based on which you are doing all the process.

Regards,

Karthik

Former Member
0 Kudos

Hi all,

Thanks for your valuable answers.My problem is solved.

Regards,

Harshada

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi..

If you need to print either of two texts then you can use an Alternative Node in Flow Logic which decides on whether the provided condition is true or not.

If there are more options out of which one needs to be printed at some cell, then you can create all the required texts put the applicable condition for their printing in the text element's Condition tab. Do it this way only if the the options have different data types.

However if they have same type, you can use a single variable in a text element, create a Program Line just above that, and depending upon the conditions, you can assign a particular fields value to the variable in text element. (As you normally do in ABAP code)

Hope this solves.

Regards,

Karthik