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: 

Displaying Data Horizontally in ALV

Former Member
0 Kudos

Dear All

This is my Final Internal Table.

Plant Pricing Procedure Material Group Qty

VA01 31 CF 1007

VA01 31 DT 358.6

VA01 31 ED 29.04

VA01 31 ML 52587

VA01 31 SG 1801

VA01 31 SR 10000

VA01 31 SU 17.6

VA01 34 CI 2763

VA01 41 AC 8

VA01 41 CDL 832

Requirement:

Plant Pricing procedure CF DT ED ML SG SR SU CI AC CDL

VA01 31 1007 358.6 29.04 52587 1801 10000 17.6

VA01 34 2763

VA01 41 8 832

How to display the data like this

5 REPLIES 5

Former Member
0 Kudos

create a internal table with plant,pricing procedure and then fileds like CF,DT etc...

loop on itab..

case matl_grp. "CF,DT

when 'CF'.

  • fills second internal table

when 'DT'.

when..

end case.

append itab2.

endloop.

this way you will revet content of internal table from verticle to horizontal.

then use ALV to print internal table 2.

0 Kudos

Dear Santosh

Thanks for the reply, but data should be placed based on Pricing procedure eg 31 ...

0 Kudos

take a internal table i_pr_gr of procing group only.


wa_pr_gr - value = 31.
append wa_pr_gr to i_pr_gr.

simialarly for other groups do the same.


loop at i_pr_gr into wa_pr_gr.


loop at_itab where pricing_group = wa_pr_gr-value..

*write initially suggested code here, only append will shift to below loop.


endloop.

append wa_itab2 to itab2.

endloop.

Former Member
0 Kudos

Hi,

Try with

AT NEW ( ur pricing field).

fill other fields respective to ur pricing fields..

ENDAT.

Thanks & Regards,

Anagha Deshmukh

Former Member
0 Kudos

Hi,

Use the idea given below...

declare an internal table which collects fieldnames.

data : begin of fs,
           fieldname(30) type c,
        end of fs.
data : itab like table of fs.

fs-fieldname = 'Plant'.
append fs to itab.

fs-fieldname = 'Pricing'.
append fs to itab.

loop at internaltable into workarea.
at new procedure.
   fs-fieldname = 'procedure'.
   append fs to itab.
endat.
endloop.

" Creating the required list
" The loop below will write the header as required by you on the list...
" i.e.  Plant  Pricing  CF DT ... and so on.... in the same line
loop at itab into fs.
  write : fs-fieldname.
endloop.

"Now entering the data
data : w_i type i.
loop at final_internal_table into workarea.
  
  at new procedure.
    write : / workarea-plant, workarea-procedure.
  endat.

  read table itab into fs with key fieldname = workarea-procedure.

" The line below will calculate the offset on the list where exactly it has to print the qty...
  w_i = sy-tabix * 30.   " as the size of the fieldname is 30 characters...

  write at w_i(30) workarea-qty.
endloop.

Please check if this code works...

let me know if you are facing problems with this code

Regards,

Siddarth