cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create Transpose ALV in webdynpro...

former_member192971
Participant
0 Kudos

Hi,

How to create a Transpose ALV(Rows to Cols and Columns to Rows) in webdynpro. I was able to create Dynamic ALV but how to make it transpose? Could any one please share a sample doc or code ??

Appreciate your help.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Uday,

Could you please provide more details on your requirement.

Regards,

Rama

former_member192971
Participant
0 Kudos

Hi Ram,

My requirement is to display the table in this Format.

                   

CustomerNum      1000     1001     1002     1003    

CustomerName     AAA     BBB     CCC     DDD

City                        AA        BB         CC       DD

Country                  US        US        US        US

As of now, I could able to display in below format using UI Container ALV Table. That means I want to Transpose the Rows & Columns of below table...

CustomerNumber     CustomerName     City     Country

1000                                AAA                  AA           US

1002                                BBB                  BB           US

1003                                CCC                 CC           US

Regards,

Uday.

ramakrishnappa
Active Contributor
0 Kudos

HI Uday,

Please follow the below steps to achieve your requirement

  • Create an internal table lt_data_target with 5 columns C1 ( for heading ), C2, C3, C4, C5 of type STRING
  • Let us say your current data is in the below table format ( table: lt_data_source )
  • Transpose logic would be as below

FIELD-SYMBOLS:

     <fs_data_target> like line of lt_data_target,

     <fs_data_source> like line of lt_data_source.

data: ls_data_target like line of lt_data_target.

              

" Prepare headings column

          do 4 times. " no. of columns

          clear ls_data_target.

          case sy-index.

               when 1.

          ls_data_target-c1 = "Customer Number".

               when 2.

          ls_data_target-c1 = "Customer Name".

               when 3.         

          ls_data_target-c1 = "city".

               when 4.        

           ls_data_target-c1 = "country".

               endcase.

          append ls_data_target to lt_data_target.

          enddo.

               data: lv_col_index type n length 1,

                       lv_col_name type string.

          Loop at lt_data_source assigning <fs_data_source>.

               lv_col_index = sy-tabix + 1.

               concatenate 'C' lv_col_index into lv_col_name.

               loop at lt_data_target assigning <fs_data_target>.

                    assign component lv_col_name of structure <fs_data_target> to <fs_value>.

               if    <fs_value> is assigned.

               " assign value from respective column

           case sy-tabix.

               when 2.          <fs_value> = <fs_data_source>-customer_num.

               when 3.          <fs_value> = <fs_data_source>-customer_name.

               when 4.         <fs_value> = <fs_data_source>-city.

               when 5.         <fs_value> = <fs_data_source>-country.

            endcase.

               endif.                   

               endloop.

          endloop.

The context node should have a node with all 5 attributes of type STRING and bind data lt_data_target to node.

Now, display the data into alv.

Regards,

Rama