Spaltenüberschriften in einem ALV m. dyn. Tabellen

Alles rund um die Sprache ABAP®: Funktionsbausteine, Listen, ALV
3 Beiträge • Seite 1 von 1
3 Beiträge Seite 1 von 1

Spaltenüberschriften in einem ALV m. dyn. Tabellen

Beitrag von BabsiCSC (ForumUser / 86 / 0 / 0 ) »
Hallo,

Weiß jemand von euch, wie man das concatenate f. Spaltenüberschriften bei dyn. Tabellen aufbaut?
Ich habe den Feldkatalog fix generiert,
*Feldkatalog aufbauen
wa_fieldcat-fieldname = 'COUNTER'.
wa_fieldcat-inttype = 'P'.
wa_fieldcat-outputlen = '3'.
wa_fieldcat-coltext = 'Variable as counter'.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'REVNR'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-coltext = 'Revision'.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'REVTX'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '40'.
wa_fieldcat-coltext = 'Rev. description'.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EQUNR'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '18'.
wa_fieldcat-coltext = 'Equipment'.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'CLASS'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '18'.
wa_fieldcat-coltext = 'Class'.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

l_class = p_class2.

CALL FUNCTION 'CLME_FEATURE_ATTR_OF_CLASS_ALL'
EXPORTING
class = l_class
classtype = '002'
language = sy-langu
* KEY_DATE = SY-DATUM
with_values = ''
* CHANGE_NUMBER = ' '
* DEFAULT_VAL_EXTRA = ' '
* I_SORTED_BY_CLASS = 'X'
TABLES
tfeatures = it_tfeatures
* TVALUES =
EXCEPTIONS
class_not_found = 1
no_authority = 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.


LOOP AT it_tfeatures INTO ls_tfeatures.

IF ls_tfeatures-atfor = 'NUM' AND ls_tfeatures-anzdz = '0'.

CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ls_tfeatures-atnam.
wa_fieldcat-inttype = 'I'.
wa_fieldcat-outputlen = ls_tfeatures-anzst.
wa_fieldcat-coltext = ''.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

ELSE.

CLEAR wa_fieldcat.
wa_fieldcat-fieldname = ls_tfeatures-atnam.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '30'.
wa_fieldcat-coltext = ''.
wa_fieldcat-seltext = wa_fieldcat-coltext.

APPEND wa_fieldcat TO it_fieldcat.

ENDIF.

ENDLOOP.
.. und möchte nun zu den Spalten die dementsprechenden Überschriften haben!

Mit ... READ TABLE it_tfeatures INTO ls_tfeatures
WITH KEY atnam = ls_objectdata-atnam. ... erscheint in jeder Spalte die selbe Überschrift (siehe screenshot).

Ich befürchte, dass ich das concatenate anders aufbauen muss?
Oder?

Code: Alles auswählen.

  IF <t_dyn_table> IS ASSIGNED.

    DATA: lt_fieldcat_tmp TYPE slis_t_fieldcat_alv,
          ls_fieldcat_tmp TYPE LINE OF slis_t_fieldcat_alv.
    DATA: l_tabname TYPE slis_tabname.


    LOOP AT it_fieldcat INTO wa_fieldcat.


      CLEAR counter.

      LOOP AT it_tfeatures INTO ls_tfeatures.

        ADD 1 TO counter.

        CONCATENATE 'AUSP1_' counter INTO lv_field.
*        CONCATENATE ls_tfeatures-atnam counter INTO lv_field.

        READ TABLE it_tfeatures INTO ls_tfeatures
          WITH KEY atnam = ls_objectdata-atnam.

*        READ TABLE lt_fieldcat_tmp INTO ls_fieldcat_tmp WITH KEY fieldname =
*         lv_field.

*        wa_fieldcat-coltext.

        IF sy-subrc = 0.

          ls_fieldcat_tmp-seltext_s = ls_fieldcat_tmp-seltext_m =
          ls_fieldcat_tmp-seltext_l = ls_fieldcat_tmp-reptext_ddic = ls_tfeatures-atbez.

          MODIFY lt_fieldcat_tmp FROM ls_fieldcat_tmp INDEX sy-tabix.

        ENDIF.

      ENDLOOP.


      MOVE-CORRESPONDING wa_fieldcat TO ls_fieldcat_tmp.
      APPEND ls_fieldcat_tmp TO lt_fieldcat_tmp.

    ENDLOOP.


    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*    i_structure_name                  = 'ZRPMM_EQUIPMENT_INSPECTION_3'
*   I_BACKGROUND_ID                   = ' '
      i_grid_title                      = 'Equipmentlist Inspection'
*   I_GRID_SETTINGS                   =
      is_layout                         =  ls_layout
      it_fieldcat                       =  lt_fieldcat_tmp
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
      i_save                            = 'X'
      is_variant                        = lv_variant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          = <t_dyn_table>
   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.

  ENDIF.
thx,
lg

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


Beitrag von uh (Specialist / 158 / 0 / 1 ) »
Hallo,

wenn du den Feldkatalog aufbaust, hast du doch schon alles am Wickel:

Code: Alles auswählen.

LOOP AT it_tfeatures INTO ls_tfeatures. 

IF ls_tfeatures-atfor = 'NUM' AND ls_tfeatures-anzdz = '0'. 

CLEAR wa_fieldcat. 
wa_fieldcat-fieldname = ls_tfeatures-atnam. 
wa_fieldcat-inttype = 'I'. 
wa_fieldcat-outputlen = ls_tfeatures-anzst. 
wa_fieldcat-coltext = ''. 
wa_fieldcat-seltext = wa_fieldcat-coltext. 
ELSE. 
CLEAR wa_fieldcat. 
wa_fieldcat-fieldname = ls_tfeatures-atnam. 
wa_fieldcat-inttype = 'C'. 
wa_fieldcat-outputlen = '30'. 
wa_fieldcat-coltext = ''. 
wa_fieldcat-seltext = wa_fieldcat-coltext. 
ENDIF. 

          wa_fieldcat-seltext_s = wa_fieldcat-seltext_m = 
         wa_fieldcat-seltext_l = wa_fieldcat-reptext_ddic = ls_tfeatures-atbez. 

APPEND wa_fieldcat TO it_fieldcat. 

ENDLOOP

Beitrag von BabsiCSC (ForumUser / 86 / 0 / 0 ) »
Hallo,

*g* hat sich schon erübrigt in der Zwischenzeit, der code sieht folgendermaßen aus ->

Code: Alles auswählen.

  IF <t_dyn_table> IS ASSIGNED.

    DATA: lt_fieldcat_tmp TYPE slis_t_fieldcat_alv,
          ls_fieldcat_tmp TYPE LINE OF slis_t_fieldcat_alv.
    DATA: l_tabname TYPE slis_tabname.


    LOOP AT it_fieldcat INTO wa_fieldcat.


      CLEAR ls_fieldcat_tmp.

      MOVE-CORRESPONDING wa_fieldcat TO ls_fieldcat_tmp.

      READ TABLE it_tfeatures INTO ls_tfeatures
            WITH KEY atnam = wa_fieldcat-fieldname.

      IF sy-subrc = 0.
        ls_fieldcat_tmp-seltext_s = ls_fieldcat_tmp-seltext_m =
        ls_fieldcat_tmp-seltext_l = ls_fieldcat_tmp-reptext_ddic = ls_tfeatures-atbez.
      ELSE.
        ls_fieldcat_tmp-seltext_s = ls_fieldcat_tmp-seltext_m =
        ls_fieldcat_tmp-seltext_l = ls_fieldcat_tmp-reptext_ddic = wa_fieldcat-fieldname.
      ENDIF.

      APPEND ls_fieldcat_tmp TO lt_fieldcat_tmp.


    ENDLOOP.


    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*    i_structure_name                  = 'ZRPMM_EQUIPMENT_INSPECTION_3'
*   I_BACKGROUND_ID                   = ' '
      i_grid_title                      = 'Equipmentlist Inspection'
*   I_GRID_SETTINGS                   =
      is_layout                         =  ls_layout
      it_fieldcat                       =  lt_fieldcat_tmp
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
      i_save                            = 'X'
      is_variant                        = lv_variant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          = <t_dyn_table>
   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.

  ENDIF.
Trotzdem danke! :-)

lg

Seite 1 von 1

Vergleichbare Themen

6
Antw.
3795
Views
Spaltenüberschriften in ALV
von Dyrdek » 26.02.2014 08:00 • Verfasst in ABAP® für Anfänger
16
Antw.
4593
Views
Feldkatalog -> Spaltenüberschriften
von Bugfix13 » 06.08.2014 08:43 • Verfasst in ABAP® für Anfänger
2
Antw.
2442
Views
ALV, Spaltenüberschriften dynamisch
von Sascha_a » 14.08.2007 21:13 • Verfasst in ABAP® für Anfänger
2
Antw.
3869
Views
SAP_CONVERT_TO_XLS_FORMAT mit Spaltenüberschriften
von Thanatos82 » 01.10.2012 11:42 • Verfasst in ABAP® Core
4
Antw.
3361
Views
Technische Spaltenüberschriften
von Bugfix13 » 28.01.2014 13:40 • Verfasst in ABAP® für Anfänger

Ü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

aRFC im OO-Kontext
vor 4 Wochen von ralf.wenzel 1 / 2405
Hilfe bei SWEC/SWE2
September 2024 von retsch 1 / 8991