Application Development 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: 

smartforms

Former Member
0 Kudos

I need to include this code in the form.

I have to check the value stored in the variable

&WA_ACCOUNTDATA-ZAMOUNT& in the smartform based on the condition type.

where should I be using it? And is that all OR should I be declaring some parameters in the form?

Because I created 'Program Lines' under the text element node where this variable is used and wrote this code it gave me an error

/: IF &wac-kschl& = 'ZBET'.

&WA_ACCOUNTDATA-ZAMOUNT&

/: ELSE

&WA_ACCOUNTDATA-ZAMOUNT(IZ)&

/: ENDIF.

Thanks for your help in advance.

Santhosh

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You have to create Alternative by right clicking the loop.After that in the General attributes of alternative,give the condition

wac-kschl = 'ZBET'.

Then in the true part of the alternative,create text element &WA_ACCOUNTDATA-ZAMOUNT&.

In False part,create text element &WA_ACCOUNTDATA-ZAMOUNT(IZ)&.

Hope this helps.

17 REPLIES 17

former_member221770
Contributor
0 Kudos

Hi Santhosh,

One possibility is to create 2 Text Nodes, one with &WA_ACCOUNTDATA-ZAMOUNT& in the General Attributes tab, and in the Conditions tab, put in &WAC-KSCHL& = 'ZBET'. The other Text Node has &WA_ACCOUNTDATA-ZAMOUNT(IZ)& in the General Attributes tab and &WAC-KSCHL& <> 'ZBET' in the Conditios tab.

What this means is that the SmartForm will check the value of WAC-KSCHL and if the Condition is satisfied, then it will print the contents of the node.

The other alternative is to define a Global Variable and make it some type of character field (we will use this variable to put inthe value of WA_ACCOUNTDATA-ZAMOUNT - let's assume it's called G_AMOUNT type CHAR20).

Create a Program Lines Node, passing in G_AMOUNT, WAC-KSCHL and WA_ACCOUNTDATA-ZAMOUNT; and passing out G_AMOUNT. Insert the following code:

if WAC-KSCHL = 'ZBET'.

G_AMOUNT = WA_ACCOUNTDATA-ZAMOUNT.

else.

G_AMOUNT = ... put in WA_ACCOUNTDATA-ZAMOUNT with the relevant formatting ...

endif.

Note, the Program Lines node allows you to insert straight ABAP code. Because SmartForms are generated to Function Modules, the Program Lines nodes are inserted straight into the generated Function Module.

Now in your Text Node, display &G_AMOUNT&.

Hope this makes sense. Let me know if you need more info or if I have misinterperated your problem.

Cheers,

Pat.

0 Kudos

hi Pat,

It's giving me an error saying that '&wac-kschl&' is unknown.

Santhosh

0 Kudos

It because you're trying to use &wac-kschl& in your code .. delete the ampersands .. the code that you posted before were for SAPSCRIPT and it won't work in smartform .. use normal ABAP code in smartform.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You have to create Alternative by right clicking the loop.After that in the General attributes of alternative,give the condition

wac-kschl = 'ZBET'.

Then in the true part of the alternative,create text element &WA_ACCOUNTDATA-ZAMOUNT&.

In False part,create text element &WA_ACCOUNTDATA-ZAMOUNT(IZ)&.

Hope this helps.

Former Member
0 Kudos

Hi santosh,

The structure WAC should exist in your import parameters ( Form Interface ) or global parameters ( Global definitions ). Check for that. In case it is there, check wheather you are providing WAC as Input parameter to your form.

Regards,

Gagan

0 Kudos

hi Gagan,

'WAC' is the work area that I have declared in the Abap program

The abap code is ......

select knumv kschl kbetr kwert kinak

from konv into table cdata

for all entries in bodyitabtotal

where konv~knumv = bodyitabtotal-knumv

and ( ( konvkbetr ne 0 or konvkwert ne 0 )

or ( konv~kschl = 'ZBET' ) ).

loop at cdata into wac where knumv = bodyitabtotal-knumv.

I do not know where and how to declare this in the smartform, can you elaborate and explain it. I am reading this data into the workarea in the abap program.

Thanks

Santhosh

Former Member
0 Kudos

Hi Santosh,

The variables declared in ABAP program are not available in Smartform. Smartform is just like a function module wehre you explicitly have to pass all the data using parameters. I guess the way you are calling smartform is wrong. I guess You are looping at internal table and within loop you are calling smartforms function. This will call smartform for eact iteration of loop.

To achieve the results, you need to pass the table to smartform and then loop within smartform to print the data.

When you go to smartform transaction, on the top left Below form attributes, you can see form interface. Double click on that. there you can define Import/export parameters just like function module.

regards,

Gagan

0 Kudos

Hi,

You have to create <b>Alternative</b> node by right clicking the loop.After that in the General attributes of alternative,give the condition

wac-kschl = 'ZBET'.

Then in the true part of the alternative,create text element &WA_ACCOUNTDATA-ZAMOUNT&.

In False part,create text element &WA_ACCOUNTDATA-ZAMOUNT(IZ)&.

For that wac should be declared in Form Interface[if you are passing from program] or should be declared in Global data as

wa type <name of the struture]

Hope this helps.If so,kindly reward points.Otherwise,get back.

0 Kudos

HI,

I followed this procedure to check the condition to have the zeros displayed on the form.

The false condition part is not working i.e for every conditon type it is displaying '0.00' in the column.

Can anyone help me out here.

thanks

Santhosh

Former Member
0 Kudos

Hi All,

We print the order date on the invoice layout using a Smartform solution. The date is in &X_HEADER-AUDAT_VAUF&. It is displayed correctly but its format depends on the user master record settings (USR01-DATFM) by SAP Standard. It is quite strange as a user can serve multiple markets where the date formats are different.

Variable &X_HEADER-AUDAT_VAUF& is displayed in a Text Node.

Do you know an 'easy' way to format the date in Smartforms (like for Write statement in ABAP) ?

thanks in advance

Szabolcs

Former Member
0 Kudos

Hi,

Create a global variable of char type and length of displayed format of date.

Create a program lines node just before writing the date. The use 'write to' as you do in ABAP to write the date with formating to new field. Write the new fields in text node instead of date field.

Hope this solves your problem.

Please try to create a new post for your problems.

Regards,

Gagan

Former Member
0 Kudos

Hi Santhosh,

Try to debug the smartform and check the value. You can debug the smartform by placing a program lines node just before the variable you want to check. In the probram lines use hard break point using statement BREAK-POINT or BREAK <Username>.

regards,

Gagan

0 Kudos

Hi Gagan,

I did as recommended but the form is not going into the debug mode.Also have abreak point at the calling function module of the ABAP program. I am not getting it.

Santhosh

Former Member
0 Kudos

Hi,

Put the program lines before the alternate node. I guess you are putting the program line within the alternate node.

Once you put the break-point, activate the form and restart the transaction( /n<TCODE>) from where you are printing the form.

Regards,

Gagan

0 Kudos

hi,

I did check in the debug mode, by default wacr-kschl is taking 'ZBET' and I do not know what to change and that is why any empty space in that field (WA_ACCOUNTDATA-ZAMOUNT) is filling up with 0.00.

How can I proceed here?

Is it something to do with the ABAP code?

defintion:

data: wac type standard table of zzconditiondata with header line,

(Before I used 'wac' as a work area but for inserting the condtion type in the form and declaring the variable in the form interface I am using it as a table)

select knumv kschl kbetr kwert kinak

from konv into table cdata for all entries in bodyitabtotal where konv~knumv = bodyitabtotal-knumv

and ( ( konvkbetr ne 0 or konvkwert ne 0 )

or ( konv~kschl = 'ZBET' ) ).

loop at cdata into wac where knumv = bodyitabtotal-knumv.

case wac-kschl.

when 'ZRAT'

.

.

.

when 'zsad'

.

.

.

when 'zbet'

.

.

.

endcase

Function module declaration

WAC = WACR

In the form

Form Interface

WACR LIKE ZZCONDITIONDATA (structure)

And I am declaring the <b>'Alternative'</b> node within the element part of the table where the 'amount' has to be displayed.

Under 'Alternative' node and 'General Attributes'

WACR-KSCHL = zbet and check the condition.

If you could take a look into it and let me know where have I gone wrong that would be helpful.

Thanks

Santhosh

Former Member
0 Kudos

Hi Santosh,

I guess you are passing only structure to the Smartform. In order to print all the data in you internal table, you need to pass the table to form. You can do that by declaring a table in tables tab of Smartform interface.

Then in smartform, you need to use tables node and in data tab use the table you passed to smartform.

For formatting, in case you want to print space if value is 0.00 then declare a variable in global data as type char 17 and then just before displaying the amount, insert a program line node and format the amount as required and move to char field. then instead of writing original amount field, write that char field.

Regards,

Gagan

Former Member
0 Kudos

Hi Santhosh,

Instead of using "loop at cdata" in your abap code, pass the cdata table to the smartform.

call function "smartform name"

exporting

.....

tables

zcdata = cdata

"cdata" is the internal table in our abap code. "zcdata" in the table that you declare in the smartform on the "Tables tab" under Global settings --> Form Interface.

In the smartform however, zcdata must be associated with a dictionary definition. You can then created a loop node in the smartform for zcdata into a work area.

Regards

Anthony