Application Development and Automation 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: 
Read only

displaying fields from z table column wise

Former Member
0 Likes
1,650

hi,

my rqmt is like this :

i have some recodrs in my z table.

im running loop and displaying records from z table using classical report.

the fields of first record should come in first column (line by line) that is

first field in 1st line, 2nd field in 2nd line.....(i used / for this)

after completion of first record then the second record fields should display in second column.(again line by line)

and third record fields in third column.... and so on...( it should be done in classical report)

can any body suggest solution for my problem.

thanks in advance,

harini.

hi,

my rqmt is like this :

i have some recodrs in my z table.

im running loop and displaying records from z table using classical report.

the fields of first record should come in first column (line by line) that is

first field in 1st line, 2nd field in 2nd line.....(i used / for this)

after completion of first record then the second record fields should display in second column.(again line by line)

and third record fields in third column.... and so on...( it should be done in classical report)

can any body suggest solution for my problem.

thanks in advance,

harini.

5 REPLIES 5
Read only

Former Member
0 Likes
1,046

Hi Harini,

To generate a field catalog automatically:

Declare an internal table of type LVC_T_FCAT .

Call function module LVC_FIELDCATALOG_MERGE and pass the DDIC structure of the output table and the internal table for the field catalog. The function module generates the field catalog and fills the internal table accordingly.

Read the rows you want to change, and adapt the fields accordingly. If your output table contains more fields than are stored in the Data Dictionary, you must append one row for each new field to the field catalog.

Read only

Former Member
0 Likes
1,046

There is something like RESERVE n lines. This can help in your case of classical report.

Through this you shud be able to loop as u have described.

Revert if you need further on this.

Read only

Former Member
0 Likes
1,046

form f_modify_table.

field-symbols: type any.

loop at assigning .

if p_field is not initial.

assign component p_field of structure to .

if sy-subrc = 0.

call function 'GENERIC_CONVERSION_EXIT_INPUT'

exporting

i_tabname = p_table

i_fieldname = p_field

input_text = p_value

importing

output_text =

exceptions

invalid_ddic_parameters = 1

invalid_input = 2

others = 3.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endif.

endif.

if p_systm is not initial.

  • Default values for system fields

loop at it_x031l into is_x031l.

if is_x031l-dtyp = 'CLNT'.

fixed_val sy-mandt.

elseif is_x031l-rollname = 'ERDAT'

or is_x031l-rollname = 'ERSDA'

or is_x031l-rollname = 'AEDAT'

or is_x031l-rollname = 'LAEDA'.

fixed_val sy-datum.

elseif is_x031l-rollname = 'ERTIM'

or is_x031l-rollname = 'AETIM'.

fixed_val sy-uzeit.

elseif is_x031l-rollname = 'ERNAM'

or is_x031l-rollname = 'AENAM'.

fixed_val sy-uname.

endif.

endloop.

endif.

endloop.

endform. "f_modify_table

Read only

Former Member
0 Likes
1,046

Hi ,

Loop through the internal table of your z table, and create another internal table ( with line type string )using FIELD-SYMBOLS , wherin the records of the z table are stored in columns . Then loop through this table to display the output.

Something like :

data : col type i,

count type i.

field-symbols : <f> type any.

col = <no of fields in z table >.

loop at it_cust into wa.

count = 1.

do col times.

assign component count of structure wa to <f> .

read table it_test index count into wa_test.

concatenate <f> wa_test-line into wa_test-line separated by space.

modify it_test index count from wa_test.

if sy-subrc <> 0.

append wa_test to it_test.

endif.

count = count + 1.

clear wa_test.

enddo.

endloop.

loop at it_test into wa_test.

write / wa_test-line.

endloop.

Regards,

Vartika

Read only

Former Member
0 Likes
1,046

Hi Harini,

Say for example you have a internal table named 'it_tab'

with two columns 'A' and 'B'.

Create a new table which contains only the column names of the table

it_tab like below,

wa_fields-field = 'A'.
APPEND wa_fields TO it_fields.

wa_fields-field = 'B'.
APPEND wa_fields TO it_fields.

So you print record column wise using the following code,

I have declared a variable 'w_value' to hold the column names inside the loop.

Field symbol declaration:

FIELD-SYMBOLS: <fs> TYPE ANY.

Logic:

LOOP AT it_fields INTO wa_fields.

  w_value = wa_fields-field.

  LOOP AT it_tab INTO wa_tab.
    ASSIGN COMPONENT w_value OF STRUCTURE wa_tab TO <fs>.
    WRITE: <fs>.
    UNASSIGN <fs>.
  ENDLOOP.

  WRITE: /.
ENDLOOP.

Hope this will help you.

Regards,

Manoj Kumar P