cancel
Showing results for 
Search instead for 
Did you mean: 

How to Transpose Rows to columns

former_member349215
Participant
0 Kudos

Hi Experts,

One of our clients is running SAP Business One, Version for SAP HANA. They have an Annual Production Report which shows the amount of Item Gruops produced (Kgs) per month in a certain year. This is a simple query output; it shows Item Groups received for the month of January=1

However, I would like some guidance on how to achieve this below. Group Name and Summmed Quantities are tranposed to Columns



Kind Regards,

Pascale.

Accepted Solutions (1)

Accepted Solutions (1)

former_member349215
Participant
0 Kudos

Solved

Decided to create crosstabs using crystal reports. It produced the intended report

Learn more about crosstabs here:

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b03a1e04-a2b9-2d10-d792-88d8755843d7&override...

Kind Regards,

Pascale.

0 Kudos

Answers (1)

Answers (1)

0 Kudos

Try below logic.......



DATA:   T_NEWTABLE TYPE REF TO DATA,
T_NEWLINE  TYPE REF TO DATA,
*t_fldcat   TYPE slis_t_fldcat_alv,
T_FLDCAT   TYPE LVC_T_FCAT,

WA_IT_FLDCAT TYPE LVC_S_FCAT,
WA_COLNO(2) TYPE N,
WA_FLNAME(5) TYPE C.


FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,   "Dynamic internal table name
                <T_DYNTABLE_FINAL> TYPE STANDARD TABLE,
               <FS_DYNTABLE> TYPE ANY,                      "Field symbol to create work area
               <FS_FLDVAL> TYPE any "Field symbol to assign values



WA_COLNO =  SY-TABIX .
     WA_IT_FLDCAT-FIELDNAME = S_EKGRP-LOW."WA_FLNAME.
     WA_IT_FLDCAT-DATATYPE = 'P'."'DMBTR'..
     WA_IT_FLDCAT-INTTYPE = 'P'.
     WA_IT_FLDCAT-DECIMALS = '2'.
     WA_IT_FLDCAT-COL_POS WA_COLNO.

     APPEND WA_IT_FLDCAT TO T_FLDCAT.


SORT T_FLDCAT BY FIELDNAME.
   DELETE ADJACENT DUPLICATES FROM T_FLDCAT COMPARING FIELDNAME.
   SORT T_FLDCAT BY COL_POS.


* Create dynamic internal table and assign to FS

   CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
     EXPORTING
       IT_FIELDCATALOG = T_FLDCAT
     IMPORTING
       EP_TABLE        = T_NEWTABLE.

   ASSIGN T_NEWTABLE->* TO <T_DYNTABLE>.
* Create dynamic work area and assign to FS
   CREATE DATA T_NEWLINE LIKE LINE OF <T_DYNTABLE>.
   ASSIGN T_NEWLINE->* TO <FS_DYNTABLE>.

former_member349215
Participant
0 Kudos

Hi Raj,

Thank you for your response.

Kind Regards,

Pascale