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: 

SmartForm: How to populate data into row and column ?

chngkhengkim
Participant
0 Kudos

Hi Experts,

Lets say I have internal table it_tab in my smartforms.

my it_tab have below data:

I want to populate/display this 6 lines of data into my smartform as below format:

May I know how to do that ?

Thank in advance.

Warm regards

Ice

1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
0 Kudos

Hi,

you have to declare a second internal table corresponding to the structure of your smartforms table

regards

Fred

11 REPLIES 11

FredericGirod
Active Contributor
0 Kudos

Hi,

you have to declare a second internal table corresponding to the structure of your smartforms table

regards

Fred

0 Kudos

Hi Fred,

I cant get you, please explain further.

Thanks!

venkateswaran_k
Active Contributor
0 Kudos

Is your number of columns are fixed?  say in example 3.

Regards,

Venkat

0 Kudos

Hi Venkat,

Yes, the columns are fixed.

Former Member
0 Kudos

Create a template with boxes , then create text element for each boxes, then drag and drop the fields for text elements according to the box of your choice..

0 Kudos

Hi Farid,

Is it create template like below ?

Anyway, how to drag and drop ?

0 Kudos

you will have to make a loop on your table, and in the logic of your screen you must loop 3 times to put the value of one line.

It's not possible, forget to break your brain. Create an internal table with 3 columns, make a simple conversion.

Fred

0 Kudos

Hi Fred,

May I ask how to convert the internal table from 1 column into 3 columns ?

0 Kudos

Create an internal table in smartform with three columns. lets say GT_ITAB has COL1/COL2/COL3 under global types.

then initialization

LOOP AT GT_TAB1_COL.

fill the data as per your need into GT_ITAB

ENDLOOP

0 Kudos

Firstly create a structure of same type in Form Interface

Right click on main window -> create -> Flow Logic -> Loop

Then in data DATA tab give the internal table name and the work area name.

Now right click on main window -> create -> template

now design your template into rows and columns according to your need.

Then wright click on Template -> Create -> text element

double click on text element -> click on Output Option tab an give the value of line - column,

continue to create text element for each box and assign line - column value. 

Now you can drag and drop your fields from work area to the text element.

venkat_aileni
Contributor
0 Kudos

Hi-

Follow below steps:

Simple logic is to define a new internal table with 3 columns and fill this table based on your it_tab entries.

Use below sample code:

TYPES: BEGIN OF t_itab,

        val1 TYPE i,

        END OF t_itab,

        BEGIN OF t_final,

        val1 TYPE i,

        val2 TYPE i,

        val3 TYPE i,

        END OF t_final.

DATA: itab TYPE STANDARD TABLE OF t_itab,

       wa_itab TYPE t_itab,

       it_final TYPE STANDARD TABLE OF t_final,

       wa_final TYPE t_final.

wa_itab-val1 = 1.

APPEND wa_itab TO itab.

wa_itab-val1 = 2.

APPEND wa_itab TO itab.

wa_itab-val1 = 3.

APPEND wa_itab TO itab.

wa_itab-val1 = 4.

APPEND wa_itab TO itab.

wa_itab-val1 = 5.

APPEND wa_itab TO itab.

wa_itab-val1 = 6.

APPEND wa_itab TO itab.

WRITE: 'Before Alignment'.

LOOP AT itab INTO wa_itab.

   WRITE: / wa_itab-val1.

ENDLOOP.

ULINE.

LOOP AT itab INTO wa_itab.

   CLEAR: WA_FINAL.

   READ TABLE ITAB INTO WA_ITAB INDEX 1.

   IF SY-SUBRC = 0.

     WA_FINAL-VAL1 = WA_ITAB-VAL1.

     DELETE ITAB INDEX 1.

   ENDIF.

   READ TABLE ITAB INTO WA_ITAB INDEX 1.

   IF SY-SUBRC = 0.

     WA_FINAL-VAL2 = WA_ITAB-VAL1.

     DELETE ITAB INDEX 1.

   ENDIF.

   READ TABLE ITAB INTO WA_ITAB INDEX 1.

   IF SY-SUBRC = 0.

     WA_FINAL-VAL3 = WA_ITAB-VAL1.

     DELETE ITAB INDEX 1.

   ENDIF.

   APPEND WA_FINAL TO IT_FINAL.

ENDLOOP.

LOOP AT IT_FINAL INTO WA_FINAL.

   WRITE: / WA_FINAL-VAL1, WA_FINAL-VAL2, WA_FINAL-VAL3.

ENDLOOP.

output for the same:

Now once you have your final internal table you can create a table in Smart Form and loop over this table. This should work.

-Venkat