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

ALV Report

singhmanishekhar
Explorer
0 Likes
1,108

Dear All,

        I have a requirement in ALV report that a particular item column (Dependent record) should come just below a particular header column for displaying relationship between them. How, It can be done.

ex: column A of header and column B of item having some relation. So, Column B will be displayed just below to column.

.......................Col A

data -------------------------------

.......................Col B

data--------------------------------

data--------------------------------

Thanks and regards

Mani

Dear All,

        I have a requirement in ALV report that a particular item column (Dependent record) should come just below a particular header column for displaying relationship between them. How, It can be done.

ex: column A of header and column B of item having some relation. So, Column B will be displayed just below to column.

.......................Col A

data -------------------------------

.......................Col B

data--------------------------------

data--------------------------------

Thanks and regards

Mani

4 REPLIES 4
Read only

former_member213275
Contributor
0 Likes
1,066
Read only

former_member209120
Active Contributor
0 Likes
1,066

Hi Manishekhar,

Try it in Hierarchial ALV, example try this code...

TYPE-POOLS : SLIS .

TYPES : BEGIN OF TY_VBAK,
         VBELN TYPE VBAK-VBELN,
         VKORG TYPE VBAK-VKORG,
         VTWEG TYPE VBAK-VTWEG,
         END OF TY_VBAK.

TYPES  : BEGIN OF TY_VBAP,
         VBELN TYPE VBAP-VBELN,
         POSNR TYPE VBAP-POSNR,
         MATNR TYPE VBAP-MATNR,
         NETWR TYPE VBAP-NETWR,
         END OF TY_VBAP.

DATA : I_VBAK TYPE TABLE OF TY_VBAK .
DATA : I_VBAP TYPE TABLE OF TY_VBAP.

DATA : WA_VBAK TYPE TY_VBAK.
DATA : WA_VBAP TYPE TY_VBAP.

DATA : I_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA : WA_FCAT LIKE LINE OF I_FCAT .

DATA : KEY TYPE SLIS_KEYINFO_ALV .

START-OF-SELECTION .
   PERFORM GET_DATA_VBAK .
   PERFORM GET_DATA_VBAP .
   PERFORM CREATE_FCAT.
   PERFORM CREATE_HIERARCHY.
   PERFORM DISPLAY_ALV .
*&---------------------------------------------------------------------*
*&      Form  GET_DATA_VBAK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_DATA_VBAK .

   SELECT * FROM VBAK
       INTO CORRESPONDING FIELDS OF TABLE I_VBAK
       UP TO 100 ROWS .
ENDFORM.                    " GET_DATA_VBAK
*&---------------------------------------------------------------------*
*&      Form  GET_DATA_VBAP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_DATA_VBAP .

   IF I_VBAK IS NOT INITIAL .
     SELECT * FROM VBAP
         INTO CORRESPONDING FIELDS OF TABLE I_VBAP
          FOR ALL ENTRIES IN I_VBAK
           WHERE VBELN = I_VBAK-VBELN .
   ENDIF .

ENDFORM.                    " GET_DATA_VBAP
*&---------------------------------------------------------------------*
*&      Form  CREATE_FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CREATE_FCAT .

   WA_FCAT-COL_POS = '1' .
   WA_FCAT-FIELDNAME = 'VBELN' .
   WA_FCAT-TABNAME = 'I_VBAK' .
   WA_FCAT-SELTEXT_M = 'Doc.NO' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .


   WA_FCAT-COL_POS = '2' .
   WA_FCAT-FIELDNAME = 'VKORG' .
   WA_FCAT-TABNAME = 'I_VBAK' .
   WA_FCAT-SELTEXT_M = 'SalesOrg' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .

   WA_FCAT-COL_POS = '3' .
   WA_FCAT-FIELDNAME = 'VTWEG' .
   WA_FCAT-TABNAME = 'I_VBAK' .
   WA_FCAT-SELTEXT_M = 'D.CHANNEL' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .

   WA_FCAT-COL_POS = '4' .
   WA_FCAT-FIELDNAME = 'POSNR' .
   WA_FCAT-TABNAME = 'I_VBAP' .
   WA_FCAT-SELTEXT_M = 'ITEM.NO' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .

   WA_FCAT-COL_POS = '5' .
   WA_FCAT-FIELDNAME = 'MATNR' .
   WA_FCAT-TABNAME = 'I_VBAP' .
   WA_FCAT-SELTEXT_M = 'MAT.NO' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .

   WA_FCAT-COL_POS = '6' .
   WA_FCAT-FIELDNAME = 'NETWR' .
   WA_FCAT-TABNAME = 'I_VBAP' .
   WA_FCAT-SELTEXT_M = 'NET.PRICE' .
   APPEND WA_FCAT TO I_FCAT .
   CLEAR WA_FCAT .




ENDFORM.                    " CREATE_FCAT
*&---------------------------------------------------------------------*
*&      Form  CREATE_HIERARCHY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CREATE_HIERARCHY .

   KEY-HEADER01 = 'VBELN' .
   KEY-ITEM01   = 'VBELN' .
ENDFORM.                    " CREATE_HIERARCHY
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV .

   CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
     EXPORTING
       I_CALLBACK_PROGRAM = SY-REPID
       IT_FIELDCAT        = I_FCAT
       I_TABNAME_HEADER   = 'I_VBAK'
       I_TABNAME_ITEM     = 'I_VBAP'
       IS_KEYINFO         = KEY
     TABLES
       T_OUTTAB_HEADER    = I_VBAK
       T_OUTTAB_ITEM      = I_VBAP.



ENDFORM.                    " DISPLAY_ALV

Output:



Read only

Former Member
0 Likes
1,066

Hi Manishekhar,

- You can make use of Hierarchical ALV to achieve above requirement.

- Your header data will be in one table and item data will be in another table.

- Define the key for relationship between two tables and pass both the tables to hierarchical ALV.

- Please refer below link for hierarchical ALV example.

ALV code for simple hierarchical list display

Read only

singhmanishekhar
Explorer
0 Likes
1,066

Hi all,

    Hierarchical ALV is fine but Column B will be always below the column A. How it will be done. Please share info related to that requirement.

Thanks and regards,

Mani