Skip to Content
0
Sep 11, 2007 at 08:30 AM

Data not being displayed through ALV

16 Views

Hello All,

This is a simple ALV report . I am not sure what is wrong with it as the data is coming in internal table till the FM REUSE ALVGRID_DISPLAY is called , but data is not being displayed in ALV. I have been trying to reason but to no avail. \

Any help appreciated.

See code below for further investigation :

TABLES : lfb1,lfa1,j_1imovend,lfbw.

TYPE-POOLS : slis.

*data : begin of it_lfb1 occurs 0,

  • bukrs like lfb1-bukrs,

  • lifnr like lfa1-lifnr,

  • end of it_lfb1.

DATA : BEGIN OF ty_itab OCCURS 0,

bukrs LIKE lfb1-bukrs, " Company Code

lifnr LIKE lfa1-lifnr, " Vendor Code

sortl LIKE lfa1-sortl, " Search Term

name1 LIKE lfa1-name1, " Name of Vendor

name2 LIKE lfa1-name2, " Address2 of Vendor name

name3 LIKE lfa1-name3, " Address3 of Vendor name

name4 LIKE lfa1-name4, " Address4 of Vendor name

ort01 LIKE lfa1-ort01, " City Of Vendor

ort02 LIKE lfa1-ort02, " District of Vendor

pstlz LIKE lfa1-pstlz, " Postal Code

regio LIKE lfa1-regio, " Region

akont LIKE lfb1-akont, " Reconciallation A/c

telf1 LIKE lfa1-telf1, " Telephone No.

hbkid LIKE lfb1-hbkid, " Housing Ba

zwels LIKE lfb1-zwels, " Payment Met"

j_1ipanno LIKE j_1imovend-j_1ipanno, "Pan No."

aedat LIKE j_1imovend-aedat, " Changed dt

usnam LIKE j_1imovend-usnam, " Changed by

sperr LIKE lfb1-sperr, " Block

j_1isern LIKE j_1imovend-j_1isern, "Service Tax Registrtion No.

qsrec LIKE lfbw-qsrec, "Rec/type

wt_subjct LIKE lfbw-wt_subjct, "Liable

witht LIKE lfbw-witht, "Tax Type Withholding Tax-Inv

wt_withcd LIKE lfbw-wt_withcd, " Tax Code Withholding Tax-Inv

erdat LIKE lfa1-erdat, "Creation Date

  • WITHT LIKE LFBW-WITHT, "Witholding Tax Payment

  • WT_WITHCD LIKE LFBW-WT_WITHCD, " With holding tax payment

END OF ty_itab.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001.

SELECT-OPTIONS:

lifnr FOR lfa1-lifnr OBLIGATORY,

bukrs FOR lfb1-bukrs OBLIGATORY,

erdat FOR lfa1-erdat OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b.

SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME.

PARAMETERS: p_vari LIKE disvariant-variant. " ALV Variant

SELECTION-SCREEN END OF BLOCK layout.

*other data needed

*field to store report name

DATA i_repid LIKE sy-repid.

  • field to check table length

DATA i_lines LIKE sy-tabix.

DATA: gt_events TYPE slis_t_event.

DATA: gt_layout TYPE slis_layout_alv.

DATA: gt_sort TYPE slis_t_sortinfo_alv.

DATA: gt_list_top_of_page TYPE slis_t_listheader.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: gt_repid LIKE sy-repid.

DATA: gt_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

DATA: gt_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.

DATA : x_layout TYPE disvariant,

x_save,

g_exit TYPE c,

spec_layout TYPE disvariant,

gs_variant TYPE disvariant.

DATA a TYPE i.

CONSTANTS: c_x TYPE c VALUE 'X'.

DATA:

  • Table with only displayed report data

itab LIKE TABLE OF ty_itab WITH HEADER LINE.

AT SELECTION-SCREEN.

  • test if specified layout exist

IF NOT p_vari IS INITIAL.

CLEAR spec_layout.

MOVE p_vari TO spec_layout-variant.

MOVE gt_repid TO spec_layout-report.

CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'

EXPORTING

i_save = x_save

CHANGING

cs_variant = spec_layout

EXCEPTIONS

wrong_input = 1

not_found = 2

program_error = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

  • popup F4 help to select a layout

CLEAR x_layout.

MOVE gt_repid TO x_layout-report.

CALL FUNCTION 'LVC_VARIANT_F4'

EXPORTING

is_variant = x_layout

i_save = x_save

IMPORTING

e_exit = g_exit

es_variant = spec_layout

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF g_exit NE 'X'.

    • set name of layout on selection screen

    p_vari = spec_layout-variant.

    ENDIF.

    ENDIF.

    INITIALIZATION.

    x_save = 'A'. "The user may save all types of a layout

    gt_repid = sy-repid.

    PERFORM eventtab_build USING gt_events[].

    PERFORM fieldcat_init USING gt_fieldcat[].

    PERFORM comment_build USING gt_list_top_of_page[].

    PERFORM layout_init USING gt_layout.

    perform sort_info using gt_sort.

    START-OF-SELECTION.

    PERFORM select_data.

    END-OF-SELECTION.

    IF spec_layout IS INITIAL.

    • if no layout was specified

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = gt_repid

    it_fieldcat = gt_fieldcat[]

    it_events = gt_events[]

    it_sort = gt_sort[]

    is_layout = gt_layout

    TABLES

    t_outtab = itab.

    IF sy-subrc <> 0.

    ENDIF.

    ELSE.

    • if no layout was specified

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_background_id = 'BUTTON_OFF_BACK'

    i_callback_program = gt_repid

    i_callback_user_command = 'USER_COMMAND'

    it_fieldcat = gt_fieldcat[]

    it_events = gt_events[]

    it_sort = gt_sort[]

    is_layout = gt_layout

    i_save = x_save

    is_variant = spec_layout

    TABLES

    t_outtab = itab.

    ENDIF.

    &----


    *& Form select_data

    &----


    • text

    ----


    FORM select_data.

    SELECT

    lifnr

    sortl

    name1

    name2

    name3

    name4

    ort01

    ort02

    pstlz

    regio

    erdat

    telf1 FROM lfa1 INTO CORRESPONDING FIELDS OF itab

    WHERE lifnr IN lifnr.

    IF sy-subrc = 0.

    APPEND itab.

    CLEAR itab.

    ENDIF.

    ENDSELECT.

    LOOP AT itab.

    SELECT bukrs

    akont

    hbkid

    zwels

    sperr

    FROM lfb1 INTO CORRESPONDING FIELDS OF itab

    WHERE lifnr = itab-lifnr AND bukrs IN bukrs.

    ENDSELECT.

    IF sy-subrc = 0.

    MODIFY itab.

    ELSE.

    DELETE itab.

    ENDIF.

    ENDLOOP.

    LOOP AT itab.

    SELECT j_1ipanno

    aedat

    usnam

    j_1isern

    FROM j_1imovend INTO CORRESPONDING FIELDS OF itab

    WHERE lifnr = itab-lifnr .

    ENDSELECT.

    IF sy-subrc = 0.

    MODIFY itab.

    ELSE.

    • delete itab.

    ENDIF.

    ENDLOOP.

    LOOP AT itab.

    SELECT qsrec

    wt_subjct

    witht

    wt_withcd

    FROM lfbw INTO CORRESPONDING FIELDS OF itab

    WHERE lifnr = itab-lifnr .

    ENDSELECT.

    IF sy-subrc = 0.

    MODIFY itab.

    ELSE.

    • delete itab.

    ENDIF.

    ENDLOOP.

    ENDFORM. "select_data

    &----


    *& Form eventtab_build

    &----


    • text

    ----


    • -->RT_EVENTS text

    ----


    FORM eventtab_build USING rt_events TYPE slis_t_event.

    DATA: ls_event TYPE slis_alv_event.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = rt_events.

    READ TABLE rt_events WITH KEY name = slis_ev_top_of_page

    INTO ls_event.

    IF sy-subrc = 0.

    MOVE gt_top_of_page TO ls_event-form.

    APPEND ls_event TO rt_events.

    ENDIF.

    ENDFORM. " EVENTTAB_BUILD

    &----


    *& Form top_of_page

    &----


    • text

    ----


    FORM top_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    i_logo = 'ENJOYSAP_LOGO'

    it_list_commentary = gt_list_top_of_page.

    ENDFORM. "top_of_page

    &----


    *& Form FIELDCAT_INIT

    &----


    • text

    &----


    &----


    *& Form FIELDCAT_INIT

    &----


    • text

    ----


    • -->P_GT_FIELDCAT[] text

    ----


    FORM fieldcat_init

    USING rt_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: ls_fieldcat TYPE slis_fieldcat_alv.

    DATA: pos TYPE i VALUE 0.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'bukrs'.

    ls_fieldcat-seltext_m = 'Company code'(001).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'lifnr'.

    ls_fieldcat-seltext_m = 'Vendor Coder'(002).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'sortl'.

    ls_fieldcat-seltext_m = 'Search Term'(003).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'name1'.

    ls_fieldcat-seltext_m = 'Vendor Name'(004).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'name2'.

    ls_fieldcat-seltext_m = 'Address-1'(005).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'name3'.

    ls_fieldcat-seltext_m = 'Address-2'(006).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'name4'.

    ls_fieldcat-seltext_m = 'Address-3'(007).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'ort01'.

    ls_fieldcat-seltext_m = 'City'(008).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'ort02'.

    ls_fieldcat-seltext_m = 'District'(009).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'pstlz'.

    ls_fieldcat-seltext_m = 'Postal Code'(010).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'regio'.

    ls_fieldcat-seltext_m = 'Region'(011).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'akont'.

    ls_fieldcat-seltext_m = 'reconc. Ac'(012).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'telf1'.

    ls_fieldcat-seltext_m = 'Tele-No.'(013).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'hbkid'.

    ls_fieldcat-seltext_m = 'Housing Ba'(014).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'zwels'.

    ls_fieldcat-seltext_m = 'Payment Mt.'(015).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'j_1ipanno'.

    ls_fieldcat-seltext_m = 'Pan No.'(016).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'aedat'.

    ls_fieldcat-seltext_m = 'Changed Dt'(017).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'usnam'.

    ls_fieldcat-seltext_m = 'Changed by'(018).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'sperr'.

    ls_fieldcat-seltext_m = 'Block'(019).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'j_1isern'.

    ls_fieldcat-seltext_m = 'S.Tax Registration No.'(020).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'qsrec'.

    ls_fieldcat-seltext_m = 'Rec/Type'(021).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'wt_subjct'.

    ls_fieldcat-seltext_m = '<Liable'(022).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'witht'.

    ls_fieldcat-seltext_m = 'Tax type witholidng tax'(023).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'wt_withcd'.

    ls_fieldcat-seltext_m = 'Tax code witholidng tax'(024).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    CLEAR ls_fieldcat.

    ls_fieldcat-col_pos = pos.

    ls_fieldcat-fieldname = 'erdat'.

    ls_fieldcat-seltext_m = 'Creation Dt'(025).

    APPEND ls_fieldcat TO rt_fieldcat.

    CLEAR ls_fieldcat.

    pos = pos + 1.

    ENDFORM. "fieldcat_init

    *& Form COMMENT_BUILD

    &----


    • text

    ----


    • -->P_GT_LIST_TOP_OF_PAGE[] text

    ----


    FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.

    DATA: ls_line TYPE slis_listheader.

    CLEAR ls_line.

    ls_line-typ = 'H'.

    ls_line-info = text-100.

    APPEND ls_line TO lt_top_of_page.

    CLEAR ls_line.

    ls_line-typ = 'A'.

    CONCATENATE ' USER ' ' : ' sy-uname

    INTO ls_line-info SEPARATED BY space.

    APPEND ls_line TO lt_top_of_page.

    CONCATENATE 'Date' ':' sy-datum+6(2) '.'

    sy-datum+4(2) '.'

    sy-datum(4) INTO ls_line-info SEPARATED BY space.

    APPEND ls_line TO lt_top_of_page.

    ls_line-typ = 'A'.

    ls_line-info = text-103.

    APPEND ls_line TO lt_top_of_page.

    ENDFORM. " COMMENT_BUILD

    &----


    *& Form LAYOUT_INIT

    &----


    • text

    ----


    • -->P_GT_LAYOUT text

    ----


    FORM layout_init USING rs_layout TYPE slis_layout_alv.

    rs_layout-zebra = 'X'.

    rs_layout-detail_popup = 'X'.

    rs_layout-colwidth_optimize = 'X'.

    ENDFORM. " LAYOUT_INIT

    &----


    *& Form SORT_INFO

    &----


    • text

    ----


    • -->P_GT_SORT text

    ----


    FORM sort_info USING rs_sort TYPE slis_t_sortinfo_alv.

    DATA: ls_sort TYPE slis_sortinfo_alv.

    CLEAR ls_sort.

    ls_sort-spos = 1.

    ls_sort-fieldname = 'lifnr'.

    ls_sort-tabname = 'ITAB'.

    ls_sort-up = 'X'.

    ls_sort-subtot = 'X'.

    APPEND ls_sort TO rs_sort.

    ENDFORM. " SORT_INFO