cancel
Showing results for 
Search instead for 
Did you mean: 

alv by using more than 2 tables

Former Member
0 Kudos
116

hi

i am tryng to join 7 tables.is it posssible to join in hierchical alv ?bcz here v r using 2 internal tables 1-header 2-item...if anybody know then pls reply me.

Amayika

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi....

Yes we can use hierarchial alv to join 7 tables......

U just refer this sample code and proceed for hierarchial.

TYPE-POOLS: SLIS.

TYPES: BEGIN OF TY_VBAK,

VBELN TYPE VBELN_VA,

ERDAT TYPE ERDAT,

NETWR TYPE NETWR,

END OF TY_VBAK.

TYPES: BEGIN OF TY_VBAP,

VBELN TYPE VBELN_VA,

POSNR TYPE POSNR,

ARKTX TYPE ARKTX,

END OF TY_VBAP.

DATA: W_VBAK TYPE TY_VBAK,

W_VBAP TYPE TY_VBAP,

w_keyinfo type SLIS_KEYINFO_ALV,

T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

W_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

data : t_VBAK type standard table of tY_VBAK

initial size 1,

t_VBAP type standard table of tY_VBAP

initial size 1.

SELECT VBELN ERDAT NETWR FROM VBAK INTO TABLE T_VBAK.

SELECT VBELN POSNR ARKTX FROM VBAP INTO TABLE T_VBAP.

w_keyinfo-header01 = 'VBELN'.

w_keyinfo-item01 = 'VBELN'.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAK'.

w_fieldcat-fieldname = 'VBELN'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'VBELN'.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAK'.

w_fieldcat-fieldname = 'ERDAT'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'ERDAT'.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAK'.

w_fieldcat-fieldname = 'NETWR'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'NETWR'.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAP'.

w_fieldcat-fieldname = 'VBELN'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'VBELN'.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAP'.

w_fieldcat-fieldname = 'POSNR'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'POSNR'.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-tabname = 'W_VBAP'.

w_fieldcat-fieldname = 'ARKTX'.

w_fieldcat-row_pos ='1'.

w_fieldcat-lowercase = 'x'.

w_fieldcat-seltext_m = 'ARKTX'.

append w_fieldcat to t_fieldcat.

PERFORM OUT.

form OUT .

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_CALLBACK_PROGRAM =

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = T_FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = 'W_VBAK'

i_tabname_item = 'W_VBAP'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = W_KEYINFO

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IR_SALV_HIERSEQ_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = T_VBAK

t_outtab_item = T_VBAP

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

&----


*& Form OUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


endform. " OUT

Hope it may help u..

Plz reward points..........

venkat_o
Active Contributor
0 Kudos

Hi kunu amayika, What is the purpose of the joining 7 tables? Why do u want to choose hierarchical ALV ? What u can do is that get the data from 7 tables and prepare 2 internal tables 1-header 1- item with atleast one key between them. and use hierarchical ALV. If you want to show 7 tables data on ALV output one by one .It is possible. We call it as Blocked ALV. Let me know the purpose . Regards, Venkat.O

Former Member
0 Kudos

Hi,thanx for responding 2 my qstn.actually i want 2 join ekko,ekpo,mseg,mkpf,rseg,rbkp.

i hav done by using inner join .but this 1 m nt getting any idea how to do.

i no the common fields in ekko,ekpo n mkpf/mseg is ebeln. n the key in mseg/mkpf /rseg is ebeln/ebelp.still m nt getting the output.

i tried by using ekko.ekpo as it_header table,and others as it_item,but values r nt coming.

can u pls help me out

regards.

amayika

Former Member
0 Kudos

hello,

Please try out the transaction V/LD, here you can find out the example with hierarchial ALV with 1 header and 2 items

Former Member
0 Kudos

Hi,

i tried but its asking for some dataes.how to get the programs.if u no then pls send me any sample programs ...

regards.

amayika

Former Member
0 Kudos

U can join 7 tables...

But the differentiation should be done based on the header and item.

u can join u r 7 tables by using read table statement.

select different field from the 7 tables...

loop at item level table..

move corresponding field into header.

move corresponding field into item.

read next table with key up table key.

move to header.

move to item.

by this method.

u can join 7 tables.

append header.

append item.

endloop.

hope it will help u.

with regards,

Kiran.G