Skip to Content
0
Former Member
Feb 09, 2007 at 06:51 AM

ALV Grid using classes

85 Views

Hi gurus,

I written a ABAP program, the output should be ALV grid using classes but it going to dump. the code i wrote is :

  • optimized on 29.01.2002

  • modified on 29.04.2002

*Modified 0n 08.02.2006 By Vinay Dasari

REPORT ymmr9029p1 NO STANDARD PAGE HEADING LINE-SIZE 220 LINE-COUNT 65.

*Begin of changes by Vinay dasari

TABLES: eban, mara, makt, stxh, ekpo, eket, ekko,marc,

mbew, mseg, mkpf, t16fv, ymrrdetl.

*End of Changes by Vinay Dasari

TYPE-POOLS : slis.

*

DATA: ok_code LIKE sy-ucomm,

g_container TYPE scrfname VALUE 'PR_STATUS_REPORT',

grid1 TYPE REF TO cl_gui_alv_grid,

g_custom_container TYPE REF TO cl_gui_custom_container.

DATA: fieldcat TYPE lvc_t_fcat,

wa_fieldcat TYPE lvc_s_fcat,

it_sort TYPE lvc_t_sort,

wa_sort TYPE lvc_s_sort.

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

SELECT-OPTIONS: s_matnr FOR mara-matnr OBLIGATORY,

s_werks FOR marc-werks OBLIGATORY.

SELECTION-SCREEN: END OF BLOCK b1.

SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS p_all RADIOBUTTON GROUP rept.

SELECTION-SCREEN COMMENT 3(8) text-005.

*Begin of changes by Vinay Dasari

PARAMETERS: pdel RADIOBUTTON GROUP rept.

SELECTION-SCREEN COMMENT 30(20) text-011.

SELECTION-SCREEN END OF LINE.

*End of Changes by Vinay Dasari

SELECTION-SCREEN: END OF BLOCK b2.

DATA:

BEGIN OF g_feldlist,

filler(10) VALUE 'OBJECT_TAB',

g_var_flag, "Liste bereits gestarted über Var

END OF g_feldlist.

*

DATA: g_selmod, "Selektionsmodus

selmod_0 VALUE '0', "Keine Selektion

selmod_s VALUE 'S', "Submit nur durch Variante

selmod_1 VALUE '1', "Selektion eines Objekts

selmod_x VALUE 'X', "Selektion mehrerer Objekte

selmod_d VALUE 'D'. "Selektion aller Objekte dunkel

*

DATA: x, w_first, w_po,

w_lead TYPE i,

w_ebeln LIKE ekpo-ebeln,

w_ebelp LIKE ekpo-ebelp,

w_tabix LIKE sy-tabix,

w_po_no LIKE thead-tdname,

w_matnr LIKE thead-tdname,

w_po_desc LIKE tline-tdline,

w_curfield(30), "to store the cursor field

w_curvalue LIKE mara-matnr. "to store the cursor value

*

DATA: tlines LIKE tline OCCURS 0 WITH HEADER LINE.

*

DATA: BEGIN OF i_mara OCCURS 0,

matnr LIKE mara-matnr,

ersda LIKE MARA-ERSDA,

ernam LIKE mara-ernam,

laeda LIKE mara-laeda,

aenam LIKE mara-aenam,

vpsta LIKE mara-vpsta,

pstat LIKE mara-pstat,

END OF i_mara.

*

DATA: BEGIN OF i_marc OCCURS 0,

werks like marc-werks,

lvorm like marc-lvorm,

bwtty like marc-bwtty,

xchar like marc-xchar,

mmsta like marc-mmsta,

mmstd like marc-mmstd,

maabc like marc-maabc,

kzkri like marc-kzkri,

END OF i_marc.

*

DATA: BEGIN OF itab OCCURS 10,

matnr LIKE i_mara-matnr,

ersda LIKE i_MARA-ERSDA,

ernam LIKE i_mara-ernam,

laeda LIKE i_mara-laeda,

aenam LIKE i_mara-aenam,

vpsta LIKE i_mara-vpsta,

pstat LIKE i_mara-pstat,

lvorm like i_marc-lvorm,

bwtty like i_marc-bwtty,

xchar like i_marc-xchar,

mmsta like i_marc-mmsta,

mmstd like i_marc-mmstd,

maabc like i_marc-maabc,

kzkri like i_marc-kzkri,

END OF itab.

START-OF-SELECTION.

PERFORM select_data.

IF pdel = 'X'.

*BEGIN OF CHANGES BY VINAY DASARI

PERFORM get_data.

ENDIF.

*END OF CHANGES BY VINAY DASARI

AT USER-COMMAND.

CHECK sy-ucomm = 'SOUP' OR sy-ucomm = 'SODN'.

*&----


*

*& Form SELECT_DATA

*&----


*

FORM select_data.

select ERSDA ERNAM LAEDA AENAM VPSTA PSTAT

from mara

into corresponding fields of table i_mara

where MATNR in s_matnr.

if sy-subrc = 0.

select werks LVORM BWTTY XCHAR MMSTA MMSTD MAABC KZKRI

from marc

into corresponding fields of table i_marc

where werks in s_werks.

endif.

ENDFORM. " SELECT_DATA

**&----

-


**

**& Form CREATE_FIELDCAT_GRID_VALUES

**&----

-


**

  • text

**----

-


**

  • --> p1 text

  • <-- p2 text

**----

-


**

*FORM create_fieldcat_grid_values.

*

*

  • PERFORM fill_fldcat USING:

  • 'WERKS' 'EBAN' 'Plant' 'E',

  • 'STATUS' 'SYST' 'Status' ' ',

  • 'MATNR' 'MARA' 'Material' 'O10',

  • 'MAKTX' 'MAKT' 'Description' 'O35',

  • 'PRUOM' 'EBAN' 'Uom' 'O05',

  • 'BANFN' 'EBAN' 'Pr No' 'O10',

  • 'BNFPO' 'EBAN' 'LinNo' 'O05',

  • 'BADAT' 'EBAN' 'Req Date' 'O10',

  • 'PRQTY' 'EBAN' 'Pr Quantity' 'O17',

  • 'DISPO' 'EBAN' 'Mcon' 'O04',

  • 'WEMNG' 'EKET' 'Sch. Qty ' 'O17',

  • 'EBELN' 'EKKO' 'Po No' 'O10',

  • 'POQTY' 'EKPO' 'Po Quantity' 'O17',

  • 'POUOM' 'EKPO' 'Uom ' 'O05 ',

  • 'BEDAT' 'EKPO' 'Po date' 'O10',

  • 'EINDT' 'EKET' 'Del Date' 'O10',

  • 'EKGRP' 'EBAN' 'Pgrp' 'O05',

  • 'ODQTY' 'EBAN' 'OD QTY' 'O17'.

    • Sort fields.

    *

    • wa_sort-spos = 1.

    • wa_sort-fieldname = 'WERKS'.

    • wa_sort-up = 'X'.

    • APPEND wa_sort TO it_sort.

    *

    • wa_sort-spos = 2.

    • wa_sort-fieldname = 'BANFN'.

    • APPEND wa_sort TO it_sort.

    *

    • wa_sort-spos = 3.

    • wa_sort-fieldname = 'BNFPO'.

    • APPEND wa_sort TO it_sort.

    *

    • wa_sort-spos = 4.

    • wa_sort-fieldname = 'MATNR'.

    • APPEND wa_sort TO it_sort.

    *

    • wa_sort-spos = 5.

    • wa_sort-fieldname = 'EBELN'.

    • APPEND wa_sort TO it_sort.

    *

    *ENDFORM. " CREATE_FIELDCAT_GRID_VALUES

    *

    *----


    *

    FORM fill_fldcat USING value(p_1342)

    value(p_1343)

    value(p_1344)

    value(p_1345).

    DATA: wrk_len TYPE i,

    wrk_str(2).

    CLEAR wa_fieldcat.

    wa_fieldcat-fieldname = p_1342.

    wa_fieldcat-ref_table = p_1343.

    wa_fieldcat-ref_field = p_1342.

    wa_fieldcat-coltext = p_1344.

    TRANSLATE p_1345 TO UPPER CASE.

    IF NOT p_1345 IS INITIAL.

    IF 'E' CO p_1345.

    wa_fieldcat-emphasize = 'X'.

    • WA_FIELDCAT-HOTSPOT = 'X'.

    ENDIF.

    IF 'O' CO p_1345.

    SEARCH p_1345 FOR 'O'.

    wrk_len = sy-fdpos + 1.

    wrk_str = p_1345+wrk_len(2).

    wa_fieldcat-outputlen = wrk_str.

    ENDIF.

    IF 'S' CO p_1345.

    wa_fieldcat-do_sum = 'X'.

    ENDIF.

    IF 'N' CO p_1345.

    wa_fieldcat-no_out = 'X'.

    ENDIF.

    ENDIF.

    APPEND wa_fieldcat TO fieldcat.

    ENDFORM. " FILL_FLDCAT

    *&----


    *

    *& Module PBO OUTPUT

    *&----


    *

    • text

    *----


    *

    MODULE pbo OUTPUT.

    SET PF-STATUS 'MAIN100'.

    IF g_custom_container IS INITIAL.

    CREATE OBJECT g_custom_container

    EXPORTING container_name = g_container.

    CREATE OBJECT grid1

    EXPORTING i_parent = g_custom_container.

    CALL METHOD grid1->set_table_for_first_display

    • EXPORTING IS_LAYOUT = it_LAY

    CHANGING it_fieldcatalog = fieldcat

    • it_sort = it_sort

    it_outtab = itab[].

    ENDIF.

    ENDMODULE. " PBO OUTPUT

    *&----


    *

    *& Module PAI INPUT

    *&----


    *

    • text

    *----


    *

    MODULE pai INPUT.

    CASE ok_code.

    WHEN 'EXIT'.

    SET SCREEN 0.

    LEAVE SCREEN.

    WHEN OTHERS.

    • do nothing

    ENDCASE.

    CLEAR ok_code.

    ENDMODULE. " PAI INPUT

    *&----


    *

    *& Form GET_DATA

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM get_data.

    *BEGIN OF CHANGES BY VINAY DASARI

    loop at i_mara.

    move i_mara[] to itab[].

    append itab.

    ENDLOOP.

    loop at i_marc.

    move i_marc[] to itab[].

    append itab.

    clear itab.

    endloop.

    CLEAR fieldcat.

    REFRESH fieldcat.

    PERFORM create_fieldcat_grid_value.

    CALL SCREEN 100.

    *END OF CHANGES BY VINAY DASARI

    ENDFORM. " GET_DATA

    *&----


    *

    *& Form CREATE_FIELDCAT_GRID_VALUE

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM create_fieldcat_grid_value.

    *BEGIN OF CHANGES BY VINAY DASARI

    PERFORM fill_fldcat USING:

    'MATNR' 'MARA' 'Mat No' 'O10',

    'ERDSA' 'MARA' 'Creation Date' 'O05',

    'ERNAM' 'MARA' 'Name of the Person created' 'O05',

    'LAEDA' 'MARA' 'Last change date' 'O15',

    'AENAM' 'MARA' 'Name of the Person created' 'O15',

    'VPSTA' 'MARA' 'Maintainance status' 'O10',

    'PSTAT' 'MARA' 'Maintain status' '035',

    'WERKS' 'MARC' 'Plant' 'O10',

    'LVORM' 'MARC' 'Flag Material' 'O35',

    'BWTTY' 'MARC' 'Valuation category' 'O17',

    'XCHAR' 'MARC' 'Batch Magmt' 'O17',

    'MMSTA' 'MARC' 'Plant Spec Material' 'O05',

    'MMSTD' 'MARC' 'Date of PSM' 'O10',

    'MAABC' 'MARC' 'ABC Indicator' 'O10',

    'KZKRI' 'MARC' 'Indicator' 'O10'.

    *END OF CHANGES BY VINAY DASARI

    ENDFORM. " CREATE_FIELDCAT_GRID_VALUE

    It is going dump due to problem in calling the container.

    best answers will be rewarded.

    Thanks in advance,

    alson.