alv grid darstellung

Getting started ... Alles für einen gelungenen Start.
7 Beiträge • Seite 1 von 1
7 Beiträge Seite 1 von 1

alv grid darstellung

Beitrag von kostonstyle (Specialist / 247 / 0 / 0 ) »
hallo abap friends

ich habe den auftrag von der firma bekommen, ein programm zu programmieren die daten mit select anweisung
aus der datenbank herrausliest. Das auslesen von daten aus datenbank ist zwar nicht das problem, aber
ich muss ausgegebenen Daten in alv grid darstellen. Ich würde mich sehr freuen wenn jemand mir helfen könnte.

danke kostonstyle

gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Beitrag von black_adept (Top Expert / 4089 / 127 / 940 ) »
Hallo kostonstyle,

in Transaktion SE83 kann man sehr viele Grid-Funktionalitäten bewundern und SAP hat für viele Beispielprogramme bereitgestellt.
z.B. Programm BCALV_GRID_DEMO

Alternativ für den Fullscreenmodus Programm BALVSD02_GRID
live long and prosper
Stefan Schmöcker

email: stefan@schmoecker.de

Beitrag von kostonstyle (Specialist / 247 / 0 / 0 ) »
vielen dank für deine antwort
noch eine Frage, wie kann ich die Texte in Feldtitel ändern, siehe bild, ist rot umrahmt, dass was ich meine

danke kostonstyle

Beitrag von black_adept (Top Expert / 4089 / 127 / 940 ) »
Doku zu Funktionsbaustein REUSE_ALV_LIST_DISPLAY anzeigen lassen und dort dann speziell die Doku zum (Tables)parameter IT_FIELDCAT anzeigen lassen. (Ganz weit unten der Bereich "Texte" ): Stichpunkte: seltext_s
live long and prosper
Stefan Schmöcker

email: stefan@schmoecker.de

Beitrag von kostonstyle (Specialist / 247 / 0 / 0 ) »
so habe es herraus gefunden.

Code: Alles auswählen.

REPORT Z_ANU_TEST.

TABLES: MARA.

TYPES: BEGIN OF ALV_OUT_TABLE_T,
         MATNR    LIKE MARA-MATNR,
         ERSDA    LIKE MARA-ERSDA,
         ERNAM    LIKE MARA-ERNAM,
         LAEDA    LIKE MARA-LAEDA,
       END OF ALV_OUT_TABLE_T.

DATA: CTL_ALV_SCARR  TYPE REF TO CL_GUI_ALV_GRID,
      CTL_CCCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      FCT_SCARR2SPFLI TYPE LVC_T_FCAT,
      T_ALV_OUT_TABLE TYPE TABLE OF ALV_OUT_TABLE_T,
      OK_CODE LIKE SY-UCOMM.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

START-OF-SELECTION.

  PERFORM FILL_ALV_TABLE CHANGING T_ALV_OUT_TABLE.
  PERFORM CREATE_FCT_SCARR2SPFLI
    CHANGING FCT_SCARR2SPFLI.
  PERFORM TURN_OFF_COLS CHANGING FCT_SCARR2SPFLI.
  PERFORM SET_FCT_SCARR2SPFLI CHANGING FCT_SCARR2SPFLI.

  CALL SCREEN 100.

END-OF-SELECTION.

* ----------------------------------------------------------
* FORMS
* ----------------------------------------------------------

FORM SET_FCT_SCARR2SPFLI
  CHANGING I_FCT_SCARR2SPFLI TYPE LVC_T_FCAT.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATNR' 'COL_POS' 1 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATNR' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'ERSDA' 'COL_POS' 2 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'ERSDA' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'ERNAM' 'COL_POS' 3 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'ERNAM' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'LAEDA' 'COL_POS' 4 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'LAEDA' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

ENDFORM.                    "set_fct_scarr2spfli

* ----------------------------------------------------------

FORM TURN_OFF_COLS
  CHANGING I_FIELDCAT TYPE LVC_T_FCAT.

  DATA: WA_FIELDCAT TYPE LVC_S_FCAT.

  LOOP AT I_FIELDCAT INTO WA_FIELDCAT.
    WA_FIELDCAT-TECH = 'X'.
    MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
  ENDLOOP.
ENDFORM.                    "turn_off_cols

* ----------------------------------------------------------

FORM CREATE_FCT_SCARR2SPFLI
  CHANGING FCT_SCARR2SPFLI TYPE LVC_T_FCAT.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME       = 'MARA'
      I_CLIENT_NEVER_DISPLAY = 'X'
    CHANGING
      CT_FIELDCAT            = FCT_SCARR2SPFLI.

********************************************************************

*  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
*    EXPORTING
*      I_STRUCTURE_NAME       = 'SCARR'
*      I_CLIENT_NEVER_DISPLAY = 'X'
*    CHANGING
*      CT_FIELDCAT            = FCT_SCARR2SPFLI.

ENDFORM.                    "create_fct_scarr2spfli

* ----------------------------------------------------------

FORM FILL_ALV_TABLE
  CHANGING T_ALV_OUT_TABLE TYPE ANY TABLE.

*  SELECT SC~CARRID SC~CARRNAME
*         SP~CONNID SP~CITYFROM SP~CITYTO
*   FROM ( SCARR AS SC INNER JOIN SPFLI AS SP
*                        ON SC~CARRID = SP~CARRID
*        )
*   INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
*   ORDER BY SC~CARRID SP~CONNID.

  SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE WHERE MATNR IN S_MATNR ORDER BY MATNR.

ENDFORM.                    "fill_alv_table

* ----------------------------------------------------------

FORM CUSTOMIZE_FIELDCATALOG
  USING VALUE(I_COLNAME) TYPE LVC_FNAME
        VALUE(I_MODFIELD) TYPE C
        VALUE(I_MODVALUE) TYPE ANY
  CHANGING I_FIELDCAT TYPE LVC_T_FCAT.

  DATA: WA_FIELDCAT TYPE LVC_S_FCAT.

  FIELD-SYMBOLS: <FS_MODFIELD> TYPE ANY.

  ASSIGN: COMPONENT I_MODFIELD OF STRUCTURE
             WA_FIELDCAT TO <FS_MODFIELD>.

  READ TABLE I_FIELDCAT WITH KEY FIELDNAME = I_COLNAME
    INTO WA_FIELDCAT.

  <FS_MODFIELD> = I_MODVALUE.

  MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.

ENDFORM.                    "customize_fieldcatalog

* ----------------------------------------------------------
* MODULES
* ----------------------------------------------------------

MODULE INIT_CONTROLS OUTPUT.
  IF CTL_CCCONTAINER IS INITIAL.
    CREATE OBJECT CTL_CCCONTAINER
       EXPORTING  CONTAINER_NAME = 'CCCONTAINER'.

    CREATE OBJECT CTL_ALV_SCARR
       EXPORTING I_PARENT = CTL_CCCONTAINER.

    CTL_ALV_SCARR->SET_TABLE_FOR_FIRST_DISPLAY(
        CHANGING IT_OUTTAB = T_ALV_OUT_TABLE
                 IT_FIELDCATALOG = FCT_SCARR2SPFLI ).
  ENDIF.
ENDMODULE.                    "init_controls OUTPUT

*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'TITEL'.
ENDMODULE.                    "status_0100 OUTPUT

*----------------------------------------------------------------------*
*  MODULE handle_input INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE HANDLE_INPUT INPUT.
  IF OK_CODE = 'EXIT'.
    LEAVE PROGRAM.
  ENDIF.
  CLEAR OK_CODE.
ENDMODULE.               "EXIT_PROGRAM
danke für hilfe

Beitrag von kostonstyle (Specialist / 247 / 0 / 0 ) »
noch eine frage, wieso wird feld 4 5 und 7 nicht angezeigt?

Code: Alles auswählen.

*&---------------------------------------------------------*
*& Report  Z_BP_FIELD_CATALOG_01
*&---------------------------------------------------------*
REPORT Z_ANU_TEST.

TABLES: MARA, MARM.

TYPES: BEGIN OF ALV_OUT_TABLE_T,
         MATNR LIKE MARA-MATNR,
         MATKL LIKE MARA-MATKL,
         MEINS LIKE MARA-MEINS,
         UMREZ LIKE MARM-UMREZ,
         MEINH LIKE MARM-MEINH,
         HOEHE LIKE MARM-HOEHE,
         UMREN LIKE MARM-UMREN,
       END OF ALV_OUT_TABLE_T.

DATA: CTL_ALV_SCARR  TYPE REF TO CL_GUI_ALV_GRID,
      CTL_CCCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      FCT_SCARR2SPFLI TYPE LVC_T_FCAT,
      T_ALV_OUT_TABLE TYPE TABLE OF ALV_OUT_TABLE_T,
      OK_CODE LIKE SY-UCOMM.

SELECT-OPTIONS: S_MATNR FOR MARM-MATNR,
                S_MATKL FOR MARA-MATKL.

START-OF-SELECTION.
  PERFORM FILL_ALV_TABLE CHANGING T_ALV_OUT_TABLE.
  PERFORM CREATE_FCT_SCARR2SPFLI
    CHANGING FCT_SCARR2SPFLI.
  PERFORM TURN_OFF_COLS CHANGING FCT_SCARR2SPFLI.
  PERFORM SET_FCT_SCARR2SPFLI CHANGING FCT_SCARR2SPFLI.

  CALL SCREEN 100.

END-OF-SELECTION.
* ----------------------------------------------------------
* FORMS
* ----------------------------------------------------------

FORM SET_FCT_SCARR2SPFLI
  CHANGING I_FCT_SCARR2SPFLI TYPE LVC_T_FCAT.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATNR' 'COL_POS' 1 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATNR' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATKL' 'COL_POS' 2 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MATKL' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MEINS' 'COL_POS' 3 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MEINS' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'UMREZ' 'COL_POS' 4 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'UMREZ' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MEINH' 'COL_POS' 5 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'MEINH' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'HOEHE' 'COL_POS' 6 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'HOEHE' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'UMREN' 'COL_POS' 7 CHANGING FCT_SCARR2SPFLI.

  PERFORM CUSTOMIZE_FIELDCATALOG
    USING 'UMREN' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.

ENDFORM.                    "set_fct_scarr2spfli

* ----------------------------------------------------------

FORM TURN_OFF_COLS
  CHANGING I_FIELDCAT TYPE LVC_T_FCAT.

  DATA: WA_FIELDCAT TYPE LVC_S_FCAT.

  LOOP AT I_FIELDCAT INTO WA_FIELDCAT.
    WA_FIELDCAT-TECH = 'X'.
    MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
  ENDLOOP.
ENDFORM.                    "turn_off_cols

* ----------------------------------------------------------

FORM CREATE_FCT_SCARR2SPFLI
  CHANGING FCT_SCARR2SPFLI TYPE LVC_T_FCAT.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME       = 'MARA'
      I_CLIENT_NEVER_DISPLAY = 'X'
    CHANGING
      CT_FIELDCAT            = FCT_SCARR2SPFLI.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME       = 'MARM'
      I_CLIENT_NEVER_DISPLAY = 'X'
    CHANGING
      CT_FIELDCAT            = FCT_SCARR2SPFLI.

ENDFORM.                    "create_fct_scarr2spfli

* ----------------------------------------------------------

FORM FILL_ALV_TABLE
  CHANGING T_ALV_OUT_TABLE TYPE ANY TABLE.

*  SELECT SC~CARRID SC~CARRNAME
*         SP~CONNID SP~CITYFROM SP~CITYTO
*   FROM ( SCARR AS SC INNER JOIN SPFLI AS SP
*                        ON SC~CARRID = SP~CARRID
*        )
*   INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
*   ORDER BY SC~CARRID SP~CONNID.

  SELECT SP~MATNR
        SP~MATKL
        SP~MEINS
        SC~UMREZ
        SC~MEINH
        SC~HOEHE
        SC~UMREN
  FROM ( MARA AS SP INNER JOIN MARM AS SC
                       ON SC~MATNR = SP~MATNR
       )
  INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
                               WHERE SP~MATNR IN S_MATNR
                               AND SP~MATKL IN S_MATKL
  ORDER BY SP~MATNR.


ENDFORM.                    "fill_alv_table

* ----------------------------------------------------------

FORM CUSTOMIZE_FIELDCATALOG
  USING VALUE(I_COLNAME) TYPE LVC_FNAME
        VALUE(I_MODFIELD) TYPE C
        VALUE(I_MODVALUE) TYPE ANY
  CHANGING I_FIELDCAT TYPE LVC_T_FCAT.

  DATA: WA_FIELDCAT TYPE LVC_S_FCAT.

  FIELD-SYMBOLS: <FS_MODFIELD> TYPE ANY.

  ASSIGN: COMPONENT I_MODFIELD OF STRUCTURE
             WA_FIELDCAT TO <FS_MODFIELD>.

  READ TABLE I_FIELDCAT WITH KEY FIELDNAME = I_COLNAME
    INTO WA_FIELDCAT.

  <FS_MODFIELD> = I_MODVALUE.

  MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.

ENDFORM.                    "customize_fieldcatalog

* ----------------------------------------------------------
* MODULES
* ----------------------------------------------------------

MODULE INIT_CONTROLS OUTPUT.
  IF CTL_CCCONTAINER IS INITIAL.
    CREATE OBJECT CTL_CCCONTAINER
       EXPORTING  CONTAINER_NAME = 'CCCONTAINER'.

    CREATE OBJECT CTL_ALV_SCARR
       EXPORTING I_PARENT = CTL_CCCONTAINER.

    CTL_ALV_SCARR->SET_TABLE_FOR_FIRST_DISPLAY(
        CHANGING IT_OUTTAB = T_ALV_OUT_TABLE
                 IT_FIELDCATALOG = FCT_SCARR2SPFLI ).
  ENDIF.
ENDMODULE.                    "init_controls OUTPUT

*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
ENDMODULE.                    "status_0100 OUTPUT

*----------------------------------------------------------------------*
*  MODULE handle_input INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE HANDLE_INPUT INPUT.
  IF OK_CODE = 'EXIT'.
    LEAVE PROGRAM.
  ENDIF.
  CLEAR OK_CODE.
ENDMODULE.                    "handle_input INPUT

Beitrag von kostonstyle (Specialist / 247 / 0 / 0 ) »
habe das problem gelöst.
noch eine frage, die arbeit mit IT_FIELDCAT wie muss ich diese schreiben in code. Ich bin relativ ein anfäger

Seite 1 von 1

Vergleichbare Themen

2
Antw.
2916
Views
ALV Grid darstellung
von abap_anfänger98 » 09.05.2021 15:52 • Verfasst in ABAP® für Anfänger
2
Antw.
1915
Views
Frage zur Darstellung.
von jondahl11 » 23.10.2006 12:45 • Verfasst in ABAP® für Anfänger
3
Antw.
2135
Views
UNICODE Darstellung
von dyv » 07.11.2014 12:30 • Verfasst in ABAP® Core
4
Antw.
957
Views
ALV Darstellung mit gui_download
von L0w-RiDer » 26.04.2019 10:23 • Verfasst in ABAP® für Anfänger
5
Antw.
2611
Views
Darstellung von Ziffern im Excel
von SAP_ENTWICKLER » 09.11.2017 13:05 • Verfasst in ABAP® Core

Über diesen Beitrag


Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.

Unbeantwortete Forenbeiträge

Daten an Tabelle binden
vor 2 Tagen von Bright4.5 1 / 767
aRFC im OO-Kontext
vor 4 Wochen von ralf.wenzel 1 / 2389
Hilfe bei SWEC/SWE2
letzen Monat von retsch 1 / 8974