cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform Loop on Internal table

Former Member
0 Kudos

Smartforms newbie here.

I'm trying to print all lines of a resulting SQL statement from a Z table (CRM system) into a service ticket i.e. where orderadm_h-guid = ztable-guid

I am doing the selection inside the Smartform itself.

If I write a code node like so:

Input Parameter: ORDERADM_H-guid

DATA:

it_z TYPE TABLE OF zpspscriptval.

SELECT zpspscriptvalanswertext zpspscriptvalanswervalue zpspscriptvalcounter zpspscriptvalguid

FROM zpspscriptval

INTO CORRESPONDING FIELDS OF TABLE it_z

WHERE zpspscriptval~guid = orderadm_h-guid.

The selection works in the code node but how do I output it? It just shows the last field in the loop when I print it via a table

Or If I do try a LOOP node with the following

Data Tab: it_z I INTO wa_z

WHERE orderadm_h-guid = wa_z-guid and then do a table output

it says it cant find component orderadm_h-guid - (its not declared in global settings but I dont have that problem when using the code as I specify it in Input Parameter)

orderadm_h-guid is not in Global definitions but Form Interface. Have tried it the other way round but it doesnt work.

Smartforms book doesnt help. Any help gratefully received.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Steve,

It looks like your table it_z needs declaring in the Global Definitions section of the form, then defining as the output parameter of your ABAP node.

Then you can create a table with it_z into wa_z in the Data tab (with a WHERE condition if you need it) remembering to use the fields from wa_z in your text elements.

Hope this is useful.

Regards,

Nick

Former Member
0 Kudos

Cheers Nick but I have already done that, I am ok with my work area WA_Z.

My problem is the code node creates my WA_Z ok, I just dont know how to print it out.

I've tried to add a LOOP node with a table associated with it thinking this will display the values. This though to me duplicates the code I've already written, but in this case with the WHERE condition it cant see ORDERADM_H-GUID. It states No component exists, but I dont get this in my ABAP code when ORDERADM_H is set as an Input Parameter.

Former Member
0 Kudos

Hi Steve,

Looking at your question again, I think it's just that the condition is the wrong way round.

WHERE orderadm_h-guid = wa_z-guid

should read

WHERE guid = orderadm_h-guid

Think that should work.

Regards,

Nick

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks both, finally got there. Bonus points awarded. Looking forward to the SF course in a few weeks.

Former Member
0 Kudos

Hi ,

You have data in internal table which u have declared globally ,

same way declare one work area also .

You have created one table (In main window ) , In data tab define internal table name.

Create loop node .

In Data tab mention Internal table .

create one text node in side loop node .

You can print &workarea-field& in text module ..

Let me know if still issue.