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: 

hierarchial display alv

Former Member
0 Kudos

hi friendz

i am new to abap.i tried executing the hierarchial display alv, but i did not get the output.though i got the field names in the output but there are no contents displayed.i am including the code here.please help me out.

rg

sandeep

REPORT ZVV_ALV_HIERARCHIAL .

*--type pools

TYPE-POOLS: slis.

*--tables declaration

TABLES: SFLIGHT,SPFLI.

*--types declaration

DATA: BEGIN OF i_SFLIGHT OCCURS 0,

CARRID LIKE SFLIGHT-CARRID,

CONNID LIKE SFLIGHT-CONNID,

FLDATE LIKE SFLIGHT-FLDATE,

END OF i_SFLIGHT.

DATA: BEGIN OF i_SPFLI OCCURS 0,

CARRID LIKE SPFLI-CARRID,

CONNID LIKE SPFLI-CONNID,

  • AIRPFROM LIKE SPFLI-AIRPFROM,

  • AIRPTO LIKE SPFLI-AIRPTO,

DISTANCE LIKE SPFLI-DISTANCE,

END OF i_SPFLI.

*--variables

DATA: i_repid LIKE sy-repid.

i_repid = sy-repid.

DATA: i_field TYPE slis_t_fieldcat_alv.

DATA: G_TABNAME_HEADER TYPE SLIS_TABNAME.

DATA: G_TABNAME_ITEM TYPE SLIS_TABNAME.

DATA: G_KEYINFO TYPE SLIS_KEYINFO_ALV.

*--select options

SELECT-OPTIONS : S_CARRID FOR SFLIGHT-CARRID .

*--initialosation

INITIALIZATION.

*--selection screen on

AT SELECTION-SCREEN .

*--start of selection

START-OF-SELECTION.

SELECT CARRID

CONNID

FLDATE

FROM SFLIGHT INTO TABLE i_SFLIGHT

WHERE CARRID IN S_CARRID.

IF NOT i_SFLIGHT IS INITIAL.

SELECT CARRID

CONNID

DISTANCE

INTO TABLE i_SPFLI FROM SPFLI

FOR ALL ENTRIES IN I_SFLIGHT

WHERE CARRID = i_SFLIGHT-CARRID.

ENDIF.

PERFORM fill_fieldcatalog1.

PERFORM fill_fieldcatalog2.

PERFORM HIERARCHY_ALV.

  • PERFORM alv_events.

G_KEYINFO-header01 = 'CARRID'.

G_KEYINFO-item01 = 'CONNID'.

G_TABNAME_HEADER = 'I_SFLIGHT'.

G_TABNAME_ITEM = 'I_SPFLI'.

&----


*& Form fill_fieldcatalog

&----


FORM fill_fieldcatalog1 .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = i_repid

i_internal_tabname = 'I_SFLIGHT'

  • i_structure_name = EKPO

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = i_repid

  • I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE = ''

CHANGING

ct_fieldcat = i_field

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDFORM. " fill_fieldcatalog

&----


*& Form fill_fieldcatalog2

&----


form fill_fieldcatalog2 .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = i_repid

i_internal_tabname = 'I_SPFLI'

  • i_structure_name = EKPO

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = i_repid

  • I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE = ''

CHANGING

ct_fieldcat = i_field

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

endform. " fill_fieldcatalog2

&----


*& Form HIERARCHY_ALV

&----


form HIERARCHY_ALV .

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = I_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = I_FIELD

  • 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 = 'A '

  • IS_VARIANT =

  • IT_EVENTS = I_EVENTS

  • IT_EVENT_EXIT =

i_tabname_header = G_TABNAME_HEADER

i_tabname_item = G_TABNAME_ITEM

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = G_KEYINFO

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = I_SFLIGHT

t_outtab_item = I_SPFLI

  • 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.

endform. " HIERARCHY_ALV

1 ACCEPTED SOLUTION

Former Member
0 Kudos

sandeep,

First... make sure that data actually exists in the SFLIGHT/SPFLI tables.

Run t-code SE16 and enter table name SFLIGHT/SPFLI.

On the selection screen, enter the same CARRID that you are entering in your program execution.

Does anything get returned from this query?

6 REPLIES 6

Former Member
0 Kudos

sandeep,

First... make sure that data actually exists in the SFLIGHT/SPFLI tables.

Run t-code SE16 and enter table name SFLIGHT/SPFLI.

On the selection screen, enter the same CARRID that you are entering in your program execution.

Does anything get returned from this query?

Former Member
0 Kudos

The table i_SPFLI is empty.

Check the values.


IF <b>i_SFLIGHT[]</b> IS NOT INITIAL.
SELECT CARRID
CONNID
DISTANCE
INTO TABLE i_SPFLI FROM SPFLI
FOR ALL ENTRIES IN I_SFLIGHT
WHERE CARRID = i_SFLIGHT-CARRID.

This populates the i_spfli table. Still working on it.

Message was edited by: Wenceslaus G

0 Kudos

Initialize G_KEYINFO and G_TABNAME* before calling ...

form HIERARCHY_ALV .

<b>G_KEYINFO-header01 = 'CARRID'.

G_KEYINFO-item01 = 'CONNID'.

G_TABNAME_HEADER = 'I_SFLIGHT'.

G_TABNAME_ITEM = 'I_SPFLI'.</b>

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

Former Member
0 Kudos

Hi

I think you have include the values

I_STRUCTURE_NAME_HEADER =

I_STRUCTURE_NAME_ITEM =

in the fm. try out.

regards

kishore

Former Member
0 Kudos

Hi

i found out the error. it is very simple.

paste the code

G_KEYINFO-header01 = 'CARRID'.

G_KEYINFO-item01 = 'CONNID'.

G_TABNAME_HEADER = 'I_SFLIGHT'.

G_TABNAME_ITEM = 'I_SPFLI'.

before the performs

regards

kishore

reward if helpful

0 Kudos

The program works fine if there is no data in the I_SPFLI. But if the table I_SPFLI is populated it shows an error like 'Unable to interpret "AA " as a number' where AA is the CARRID.

If the header01 is changed to CONNID the program works well. Here is the program.

TYPE-POOLS: slis.

*--tables declaration
TABLES: SFLIGHT,SPFLI.

*--types declaration
DATA: BEGIN OF i_SFLIGHT OCCURS 0,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID,
FLDATE LIKE SFLIGHT-FLDATE,
END OF i_SFLIGHT.

DATA: BEGIN OF i_SPFLI OCCURS 0,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
* AIRPFROM LIKE SPFLI-AIRPFROM,
* AIRPTO LIKE SPFLI-AIRPTO,
DISTANCE LIKE SPFLI-DISTANCE,
END OF i_SPFLI.

*--variables
DATA: i_repid LIKE sy-repid.

i_repid = sy-repid.

DATA: i_field TYPE slis_t_fieldcat_alv.
DATA: i_field2 TYPE slis_t_fieldcat_alv.


DATA: G_TABNAME_HEADER TYPE SLIS_TABNAME.
DATA: G_TABNAME_ITEM TYPE SLIS_TABNAME.
DATA: G_KEYINFO TYPE SLIS_KEYINFO_ALV.
*--select options
SELECT-OPTIONS : S_CARRID FOR SFLIGHT-CARRID .

*--initialosation
INITIALIZATION.
*--selection screen on
AT SELECTION-SCREEN .
*--start of selection
START-OF-SELECTION.
SELECT CARRID
CONNID
FLDATE
FROM SFLIGHT INTO TABLE i_SFLIGHT
WHERE CARRID IN S_CARRID.


IF i_SFLIGHT[] IS NOT INITIAL.
SELECT CARRID
CONNID
DISTANCE
INTO TABLE i_SPFLI FROM SPFLI
FOR ALL ENTRIES IN I_SFLIGHT
WHERE CARRID = i_SFLIGHT-CARRID.

IF sy-subrc NE 0.
  MESSAGE e001(z538msg).
 ENDIF.
ENDIF.

PERFORM fill_fieldcatalog1.
PERFORM fill_fieldcatalog2.
PERFORM HIERARCHY_ALV.
* PERFORM alv_events.

G_KEYINFO-header01 = 'CARRID'.
G_KEYINFO-item01 = 'CONNID'.
G_TABNAME_HEADER = 'I_SFLIGHT'.
G_TABNAME_ITEM = 'I_SPFLI'.



*&---------------------------------------------------------------------*
*& Form fill_fieldcatalog
*&---------------------------------------------------------------------*
FORM fill_fieldcatalog1 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SFLIGHT'
* i_structure_name = EKPO
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
* I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. " fill_fieldcatalog

*&---------------------------------------------------------------------*
*& Form fill_fieldcatalog2
*&---------------------------------------------------------------------*
form fill_fieldcatalog2 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SPFLI'
* i_structure_name = EKPO
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
* I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

endform. " fill_fieldcatalog2



*&---------------------------------------------------------------------*
*& Form HIERARCHY_ALV
*&---------------------------------------------------------------------*
form HIERARCHY_ALV .
<b>*G_KEYINFO-header01 = 'CARRID'.</b>
<b>G_KEYINFO-header01 = 'CONNID'.</b>
G_KEYINFO-item01 = 'CONNID'.
G_TABNAME_HEADER = 'I_SFLIGHT'.
G_TABNAME_ITEM = 'I_SPFLI'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = I_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IS_LAYOUT =
IT_FIELDCAT = I_FIELD
* 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 = 'A'
* IS_VARIANT =
* IT_EVENTS = I_EVENTS
* IT_EVENT_EXIT =
i_tabname_header = G_TABNAME_HEADER
i_tabname_item = G_TABNAME_ITEM
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = G_KEYINFO
* IS_PRINT =
* IS_REPREP_ID =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = I_SFLIGHT
t_outtab_item = I_SPFLI
* 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.

endform. " HIERARCHY_ALV