Skip to Content
0
Apr 14 at 08:14 AM

Can RTTS help to make just a part of the needed output columns dynamic?

105 Views

I need to change a program which currently - in addition to lots of other information - gets configuration data for a configured material via function module VC_I_GET_CONFIGURATION. I already searched for an answer and by reading through some of them guess that it will be "No" but thought I'd put it out there anyway before reporting back to the requester.

This is how the output structure is currently defined via the DDIC:

.. many other fields and then the 9 paired fields for the configuration data (characterstics and attributes):

The MKMn_WRT and MKMn fields are filled somewhat dynamically based on the output from the FM:

        CALL FUNCTION 'VC_I_GET_CONFIGURATION'
          EXPORTING
            instance            = ls_vbap-cuobj
          TABLES
            configuration_idoc  = lt_konf
          EXCEPTIONS
            instance_not_found  = 1
            internal_error      = 2
            no_class_allocation = 3
            instance_not_valid  = 4
            OTHERS              = 5.
        IF sy-subrc <> 0.
          CLEAR: ls_vbap-mkm1, "... mkm9
          lv_flg_fehler_zeile   =   gc_x.  "Zeile farblich markieren
        ELSE.
*         Get configuration characteristics and attribute into table
          LOOP  AT  pt_merkm_sel   INTO  ls_merkm_sel.
            lv_ind_sel       =  sy-tabix.
            READ   TABLE lt_konf   INTO  ls_konf              "<--- only the first fitting entry is retreived, 
             WITH  KEY atnam       =  ls_merkm_sel-name_char. "<--- but there can be more
            IF  sy-subrc     EQ 0.
              PERFORM uebertr_merkmal
               USING ls_vbap ls_konf lv_ind_sel.
              IF  lv_flag_les EQ   gc_x.
                PERFORM feld_ausgabe_wert_festlegen
                 USING ls_param ls_konf lv_ind_sel.
              ENDIF.
            ENDIF.
          ENDLOOP.
*         Text for header only needs to be determined once
          CLEAR  lv_flag_les.
        ENDIF.


FORM uebertr_merkmal
 USING
  ps_vbap         TYPE  ts_vbap_gek
  ps_konf         TYPE  ts_konf
  pv_ind_sel      TYPE  i
  .
*
  FIELD-SYMBOLS:
   <lv_merkm_feld> TYPE any.
  DATA:
    lv_feld         TYPE  char30.
  CONSTANTS:
    lc_feld_name  TYPE  char30  VALUE 'ps_vbap-mkm',
    lc_feld_name1 TYPE  char30  VALUE '_wrt'.
* Description of characterstic value
  lv_feld            =   lc_feld_name.
  lv_feld+11(1)      =   pv_ind_sel.
  ASSIGN  (lv_feld)  TO  <lv_merkm_feld>.
  <lv_merkm_feld>    =   ps_konf-atwtb.
* characterstic value
  lv_feld+12(4)      =   lc_feld_name1.
  ASSIGN  (lv_feld)  TO  <lv_merkm_feld>.
  <lv_merkm_feld>    =   ps_konf-atwrt.
*
ENDFORM.                    " UEBERTR_MERKMAL


FORM feld_ausgabe_wert_festlegen
 USING
  ps_param        TYPE  ts_param
  ps_konf         TYPE  ts_konf
  pv_ind_sel      TYPE  i
  .
*
  DATA:
    lv_ind      TYPE  i,
    lv_ind1     TYPE  i,
    lv_ind_c(1) TYPE  c.

* Get description for ATNAM
  TRY.                           
      CALL METHOD lo_variant->check_component_for_mat2 
        EXPORTING
          iv_atwrt = ps_konf-atwrt
          iv_atnam = ps_konf-atnam                     
        IMPORTING
          ev_matnr = lv_matnr.
    CATCH zcx_de1l0vc_variants .                          
  ENDTRY.                            
*     Prüfen auf Baugruppen
  IF lv_matnr IS NOT INITIAL.                              
    lv_ind_c     =  pv_ind_sel.
    CONCATENATE  ps_param-ausgabe_wert
                 lv_ind_c
           INTO  ps_param-ausgabe_wert.
  ENDIF.
*
ENDFORM.                    " FELD_AUSGABE_WERT_FESTLEGEN

For the ALV-output, the headings and column properties are filled "manually" for the nine pairs of possible characterstics:

      WHEN 'KUNNR'.
        ps_fieldcat-ddictxt      =  'M'.     "Für Langtext
        ps_fieldcat-seltext_l    =  'Auftraggeber'.
        ps_fieldcat-seltext_m    =  'Auftraggeber'.
        ps_fieldcat-seltext_s    =  'Auftr-Geb.'.
      WHEN 'MKM1_WRT'.
        lv_ind          =    ps_fieldcat-fieldname+3(1).
        lv_ind_c        =    ps_fieldcat-fieldname+3(1).
        IF   lv_ind_max GE   lv_ind
         AND lv_ind_c   CO   ps_param-ausgabe_wert.
          READ  TABLE  pt_merkm_sel  INTO  ls_merkm_sel INDEX lv_ind.
          ps_fieldcat-ddictxt      =  'L'.     "Für Langtext
          CONCATENATE ls_merkm_sel-descr
                      gc_wert
                 INTO ps_fieldcat-seltext_l
                      SEPARATED BY space.
          ps_fieldcat-seltext_m    =  ls_merkm_sel-descr(20).
          ps_fieldcat-seltext_s    =  ls_merkm_sel-descr(10).
        ELSE.
          ps_fieldcat-tech        = 'X'.
        ENDIF.
      WHEN 'MKM1'.
        lv_ind          =    ps_fieldcat-fieldname+3(1).
        IF   lv_ind_max GE   lv_ind.
          READ  TABLE  pt_merkm_sel  INTO  ls_merkm_sel INDEX lv_ind.
          ps_fieldcat-ddictxt      =  'L'.     "Für Langtext
          CONCATENATE ls_merkm_sel-descr
                      gc_bez
                 INTO ps_fieldcat-seltext_l
                      SEPARATED BY space.
          ps_fieldcat-seltext_m    =  ls_merkm_sel-descr(20).
          ps_fieldcat-seltext_s    =  ls_merkm_sel-descr(10).
        ELSE.
          ps_fieldcat-tech        = 'X'.
        ENDIF.

I think that we have two options:

The first is to "simply" tweak the existing logic and fill another "pair" of characterstic columns for other than just the first fitting entry in LT_KONF for ATNAM. This could however lead to not all characterstics initially requested to be shown because we could be "running out of columns".

The second might be to build the MKMn part of the structure dynamically with the help of RTTS based on the data actually found in the selection. To do this, I think that I'd first have to get individual entries into what is currently LT_VBAP, one for each characterstic found in LT_KONF with all the other fields showing the content they now have. Once that is done, the RTTS logic could somehow kick in to build as many columns as needed for the characterstic values found for all entries.

Is this second option technically possible and even feasible to entertain? Note that the selection for the program allows just one material number but many sales orders. And each line item can have a different setup of this configurable material.

Oh, and I'm not really sure if I'd able to fully wrap my head around what I guess will be quite some involved piece of dynamic coding required for option 2.

We are on NW 7.50 EHP8.

Thanks much for any input you might have!

Cheers

Bärbel