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: 

How to capture field values dynmacially and process?

former_member184119
Active Contributor
0 Kudos

I am have a interntable itab with Fields as F1,F2,F4,F4,F5.

Requirement is user will maintain one of those fields in TVARVC Example F2 , F4 he will maintain in TVARVC.

We need to capture the fields in the report and validate if they are initial or not then dont process them to the output if they are initial.

as of now. I am doing like.

Loop at itab into wa.

check wa-f2 is not intial and wa-f4 is not initial. ( If I have f2 ,f4 in dynamic table , they can be any fields or all fields)

How to keep this condition?

move wa to jtab.

append Jtab.

endloop.

Thanks in advance.

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

Check fields in TVARVC fields one by one.

For each you can use dynamic "ASSIGN component OF STRUCTURE wa", where component is name of field (i.e. 'F2' value in TVARVC etc.). Explore ABAP documentation link for more info.

-- Tomas --
11 REPLIES 11

Tomas_Buryanek
Active Contributor

Check fields in TVARVC fields one by one.

For each you can use dynamic "ASSIGN component OF STRUCTURE wa", where component is name of field (i.e. 'F2' value in TVARVC etc.). Explore ABAP documentation link for more info.

-- Tomas --

0 Kudos

Thank you Tom any live example, thank you very much !!

0 Kudos

saslove.sap ?

ASSIGN 'F2' OF STRUCTURE wa TO FIELD-SYMBOL(<field>).
-- Tomas --

0 Kudos

Thanks Tom.

What is wa and <field> types here, sorry just came back from meeting. TIA.

0 Kudos

This is giving syntax error, please respond, thanks. error' OF STRUCTURE WA is not expected

ASSIGN'F2'OFSTRUCTURE wa TO FIELD-SYMBOL(<field>).

The correct syntax is Thanks for the direction

ASSIGN commponent 'F2' OF STRUCTURE wa TO FIELD-SYMBOL(<field>).

0 Kudos

Tom, can you correct the below code ? whats wrong over there?

In Lwa_mapping I have column names Pernr, CC, DIV.

for pernr I am getting the <FIELD> symbol created, but later for next column, I am unable to, can you let me know the reason?

Like for next column it is CC but <FIELD> is initial and unable to get the data.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

LOOP AT lt_mapping INTO lwa_mapping.
ASSIGN COMPONENT lwa_mapping-inputa OF STRUCTURE lwa_ftab TO FIELD-SYMBOL(<field>).
IF <field> IS ASSIGNED.
IF <field> IS INITIAL.
APPEND lwa_ftab TO lt_key_miss.
CLEAR lwa_ftab.
UNASSIGN <field>.
REJECT.
ELSE.
UNASSIGN <field>.
ENDIF.
ENDIF.

ENDLOOP.

0 Kudos

Solved by self !! Column name have spaces so unable to do anything.

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button. ANSWER is only to propose a solution. You also have an option to convert your answer into a comment. Or even delete it.

former_member184119
Active Contributor
0 Kudos

Hi Sandra, when I click edit I dont see converting of answer to Comment, kindly advise, after clicking edit whats next ?

former_member184119
Active Contributor
0 Kudos

Yes 🙂 ......