BDC Possible on ALV?

Hi All,
            We have a requirement to write BDC on the ALV. Is it possible to write BDC on ALV Grid?

you don't get line selection with bdc ok code but with the chk field in the alv structure
declare a field CHK type xfeld in you're alv structure
here the parts you need in the alv to make it work
with this example a user can select multiple tasks and click on a button to edit them. when 1 is saved or skipped then automaticaly the next one in the selection is executed
  slayout-box_fieldname = 'CHK'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
      i_callback_program                = h_repid
      i_callback_pf_status_set          = 'SET_PF_STATUS'
      i_callback_user_command           = 'USER_COMMAND'
FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN 'WIJZ'.
      LOOP AT ta_zcs_operatielijst_alv WHERE chk = 'X'.
        REFRESH bdcdata.
        PERFORM display_change_maintenance_ord USING
                                               ta_zcs_operatielijst_alv-aufnr
                                               ta_zcs_operatielijst_alv-vornr
                                               con_change
                                               CHANGING
                                               h_transaction_code.
        CALL TRANSACTION f_tcode USING bdcdata MODE 'E' UPDATE  'S'.
      ENDLOOP.
      COMMIT WORK.
endform.
FORM display_change_maintenance_ord USING    p_aufnr
                                             p_vornr
                                             p_activity TYPE c
                                    CHANGING p_transaction_code
                                               LIKE sy-tcode.
  DATA: flg_transaction_found TYPE flag.
  PERFORM bdc_dynpro USING 'SAPLCOIH' '0101'.
  PERFORM bdc_field  USING 'CAUFVD-AUFNR' p_aufnr.
  CHECK NOT p_vornr IS INITIAL.
  PERFORM bdc_field  USING 'BDC_OKCODE' 'VGUE'.
  PERFORM bdc_dynpro USING 'SAPLCOIH'   '3000'.
  PERFORM bdc_field  USING 'BDC_OKCODE' 'OBSE'.
  PERFORM bdc_dynpro USING 'SAPLCO05' '2010'.
  PERFORM bdc_field  USING 'RCOLS-VORNR' p_vornr.
  PERFORM bdc_field  USING 'RC27X-OBJECT' 'O'.
  PERFORM bdc_dynpro USING 'SAPLCOIH'   '3000'.
  PERFORM bdc_field  USING 'RC27X-FLG_SEL(1)' 'X'.
  PERFORM bdc_field  USING 'BDC_OKCODE' 'VGD3'.
  PERFORM bdc_dynpro USING 'SAPLCOIH'   '3800'.
  IF p_activity = con_change.
    p_transaction_code = 'IW32'.
  ELSEIF p_activity = con_display.
    p_transaction_code = 'IW33'.
  ENDIF.
  flg_transaction_found = 'X'.
ENDFORM.                               " DISPLAY_CHANGE_MAINTENANCE_ORD
kind regards
arthur

Similar Messages

  • BDC Recording for ALV Grid in containers

    Hi All,
    I have to record for BDC on an ALV Grid (OOABAP). I am not able to record selection of rows in ALV grid.How do i select rows in the grid dynamically that is while recording.
    Thanks n Regards,
    Santosh Kotra.

    Usually it is not a good idea to do recording over a transaction which includes frontend gui controls, such as, tree controls and ALV controls, for this exact reason, among others.  Try to use a older version of the transactoin if possible or a BAPI.  For example, if you are trying to do a recording over say  ME21N, it is recommended to do the recording over the non-enjoy transaction,  ME21,  or simply use the BAPI.
    Regards,
    Rich Heilman

  • Create locked HR record in BDC - possible???

    Is it possible to create a locked infotype record via a BDC session?
    Let me be more specific: We have a strange calculation for benefits eligible salary. So we use a program that performs that calculation and updates insurance records (it0168) with the correct coverage amount in the COVOV field in a BDC session. Now we have a new requirement that places a limit on the coverage amount w/o EoI. The BDC session will need to create two records for persons over the max - one with the limit amount, another locked record with the calc'd amount and EoI indicators. Both records will have the same start and end date.
    I've tried a number of different things, but the infotype key for both records (except for the lock indicator) is identical. So, one record just overwrites the other.
    Any help is greately apreciated.
    - George

    Hi George,
    1. Either we use BDC, or HR_INFOTYPE_OPERATION
       we cannot create duplicate records.
       ( i have tried the same)
    2. The Primary Key fields for any infotype table are
    SUBTY
    OBJPS
    SPRPS
    ENDDA
    BEGDA
    SEQNR
    3. If it is mandatory that BEGDA and ENDA (start and enddate)
    have to be the same, then the only option left is
    using the remaining field combination
    ie. SEQNR
    4. But SEQNR is probably not avaialble in BDC,
    5. For that purpose the other option is using
      FM HR_INFOTYPE_OPERATION
       (specify the SEQNR )
      This will definitely create a new record.
      ( i have tried the same)
    6. ANOTHER MOST IMPORTANT THING IS
       Will sap HR take into consideration this
      new record with SEQNR = 1 or SEQNR = 2
      in its standard business process.
       Or will it ignore it ,etc .
    7. So Before just dumping new record
      with new SEQNR, it is very crucuial to
      identify the problems.
    Hope the above helps.
    Regards,
    Amit M.

  • Hi want to know if possible in ALV report

    Hi all
    i have a req  where i have to generate a alv report where   the req is as follows
    the column header is like  below
    catagory1        catogory2            catagory3
    ca1 ca2  ca3    cb1 cb2 cb3         cc1 cc2 cc3
    Plz help me fast . by giving if its possible if yes how.
    thanks and regards
    avik

    REPORT  ZHIERSEQ_ALV.
    TYPE-POOLS: slis.                    " ALV Global types
    CONSTANTS :
      c_x VALUE 'X',
      c_gt_vbap TYPE slis_tabname VALUE 'GT_VBAP',
      c_gt_vbak TYPE slis_tabname VALUE 'GT_VBAK'.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
    PARAMETERS p_max(02) TYPE n DEFAULT '10' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_2 FOR FIELD p_expand. "#EC NEEDED
    PARAMETERS p_expand AS CHECKBOX DEFAULT c_x.
    SELECTION-SCREEN END OF LINE.
    TYPES :
    1st Table
      BEGIN OF ty_vbak,
        vbeln TYPE vbak-vbeln,             " Sales document
        kunnr TYPE vbak-kunnr,             " Sold-to party
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
        erdat TYPE vbak-erdat,             " Creation date
        waerk TYPE vbak-waerk,             " SD document currency
        expand TYPE xfeld,
      END OF ty_vbak,
    2nd Table
      BEGIN OF ty_vbap,
        vbeln TYPE vbap-vbeln,             " Sales document
        posnr TYPE vbap-posnr,             " Sales document
        matnr TYPE vbap-matnr,             " Material number
        arktx TYPE vbap-arktx,             " Material description
        netwr TYPE vbap-netwr,             " Net Value of the Sales Order
        waerk TYPE vbap-waerk,             " SD document currency
      END OF ty_vbap.
    DATA :
    1st Table
      gt_vbak TYPE TABLE OF ty_vbak,
    2nd Table
      gt_vbap TYPE TABLE OF ty_vbap.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
      v_2 = 'With ''EXPAND'' field'.
    START-OF-SELECTION.
    Read Sales Document: Header Data
      SELECT vbeln kunnr netwr waerk erdat
        FROM vbak
          UP TO p_max ROWS
        INTO CORRESPONDING FIELDS OF TABLE gt_vbak.
      IF gt_vbak[] IS NOT INITIAL.
      Read Sales Document: Item Data
        SELECT vbeln posnr matnr arktx netwr waerk
          FROM vbap
          INTO CORRESPONDING FIELDS OF TABLE gt_vbap
           FOR ALL ENTRIES IN gt_vbak
         WHERE vbeln = gt_vbak-vbeln.
      ENDIF.
    END-OF-SELECTION.
      PERFORM f_display.
          Form  F_DISPLAY
    FORM f_display.
    Macro definition
      DEFINE m_fieldcat.
        ls_fieldcat-tabname = &1.
        ls_fieldcat-fieldname = &2.
        ls_fieldcat-ref_tabname = &3.
        ls_fieldcat-cfieldname = &4.       " Field with currency unit
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        ls_sort-tabname = &1.
        ls_sort-fieldname = &2.
        ls_sort-up        = c_x.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_layout   TYPE slis_layout_alv,
        ls_keyinfo  TYPE slis_keyinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv," Sort table
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv." Field catalog
      ls_layout-group_change_edit = c_x.
      ls_layout-colwidth_optimize = c_x.
      ls_layout-zebra             = c_x.
      ls_layout-detail_popup      = c_x.
      ls_layout-get_selinfos      = c_x.
      IF p_expand = c_x.
        ls_layout-expand_fieldname  = 'EXPAND'.
      ENDIF.
    Build field catalog and sort table
      m_fieldcat c_gt_vbak 'VBELN' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'KUNNR' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'NETWR' 'VBAK' 'WAERK'.
      m_fieldcat c_gt_vbak 'WAERK' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'ERDAT' 'VBAK' ''.
      m_fieldcat c_gt_vbap 'POSNR' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'MATNR' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'ARKTX' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'NETWR' 'VBAP' 'WAERK'.
      m_fieldcat c_gt_vbap 'WAERK' 'VBAP' ''.
      m_sort c_gt_vbak 'KUNNR'.
      m_sort c_gt_vbap 'NETWR'.
      ls_keyinfo-header01 = 'VBELN'.
      ls_keyinfo-item01 = 'VBELN'.
      ls_keyinfo-item02 = 'POSNR'.
    Dipslay Hierarchical list
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = ls_layout
          it_fieldcat             = lt_fieldcat
          it_sort                 = lt_sort
          i_tabname_header        = c_gt_vbak
          i_tabname_item          = c_gt_vbap
          is_keyinfo              = ls_keyinfo
          i_save                  = 'A'
        TABLES
          t_outtab_header         = gt_vbak
          t_outtab_item           = gt_vbap
        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.
    ENDFORM.                               " F_LIST_DISPLAY
          Form USER_COMMAND                                             *
    FORM user_command USING i_ucomm     TYPE sy-ucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
      DATA ls_vbak TYPE ty_vbak.
      CASE i_ucomm.
        WHEN '&IC1'.                       " Pick
          CASE is_selfield-tabname.
            WHEN c_gt_vbap.
            WHEN c_gt_vbak.
              READ TABLE gt_vbak INDEX is_selfield-tabindex INTO ls_vbak.
              IF sy-subrc EQ 0.
              Sales order number
                SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
              Display Sales Order
                CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND

  • ALV record capturing when BDC is used.

    Dear All,
    I have an ALV,in which only one record will get diplayed which has to be processed.
    i have to use a BDC for the same.
    How will the record selection be captured.Is it Possible to run a BDC on an ALV
    Regards,
    Varun

    Hi Varun,
    You can select the row, for running the BDC with the same record, in various ways:
    1. You can use a double click event on the row. On this event, you can write the code for the BDC. The record would be already present in your work area or internal table
    2. In case you still wish to select the row and then proceed, then you can use get_selected_rows method.
      E.g. CALL METHOD grid1->get_selected_rows
                  IMPORTING
                      ET_ROW_NO = lt_Selected_Rows.
      This will give you the selected row number based on which you can fetch the record from table and use it for the BDC.
    Let me know if this was helpful.
    Regards,
    Aparna Alashe.

  • Possible max no. of events in alv

    Hi
    is there any maximum no of events possible in ALV reporting.
    i.e. what is the maximum no of events of alv possible in one program.

    Hi ,
    The possible events in ALV are,
    'ITEM_DATA_EXPAND',
    'REPREP_SEL_MODIFY',
    'CALLER_EXIT',
    'USER_COMMAND',
    'TOP_OF_PAGE',
    'DATA_CHANGED',
    'TOP_OF_COVERPAGE',
    'END_OF_COVERPAGE',
    'FOREIGN_TOP_OF_PAGE',
    'FOREIGN_END_OF_PAGE',
    'PF_STATUS_SET',
    'LIST_MODIFY',
    'TOP_OF_LIST',
    'END_OF_PAGE',
    'END_OF_LIST',
    'AFTER_LINE_OUTPUT',
    'BEFORE_LINE_OUTPUT',
    'SUBTOTAL_TEXT',
    'CONTEXT_MENU'.
    Regards,
    Balakumar.G.
    Reward Points if helpful.

  • ALV Grid row selection possible options

    Hello Experts,
    I have an ALV Grid output with rows color codes based on certain status for each rows.Now when the user selects one or more lines to do the next process, what happens now as sap standard is the selected lines becomes highlighted ( kind of yellowish) and the selection button gets pressed.
    But what the user is requesting is ,lets say he selects one blue and another red line, then both becomes yellow (because of the SAP standard highlighting) ...he would like those line colors to be still red and blue and only the selection button pressed.
    Is there a way to do that is ALV grid? I'm trying to convince him to look at the status colum if he gets confused with what colors he selected or I will have to use a checkbox field as the first column and and hide the ALV selection option.
    But was curious to find if this is possible in ALV?Or any other suggestions to handle this requirement is welcome.
    Mat

    Hi Mat,
    I am curious if your user is so arogant when he buys a car too. Does he say to dealer "Sorry I don't want this gear lever to be placed here and here, I want it a litte bit higher. Can you please fix that?". This sounds like you are struggling with dumb user. I have never heard of someone complaining that the standard highlight is in wrong color. You already provided to him row colors, right? I think most of the users would be hugging you for such facilities.
    I think in your case as the user is inalterable you should go for the checkboxes as you say. This way maybe you will somehow satisfy his needs (as the row colors will be kept even during selection). Personally I wouldn't bother such requirements. As long as the program reports correct data, he should not complain at all.
    Good luck then
    Marcin

  • BDC and alvs

    What is the best way to learn BDC's and ALV's?

    Hi,
    For BDC,refer the following links.
    http://sappoint.com/abap/
    http://www.sapgenie.com/abap/bdc.htm
    For BDC,if you record the data using SHDB and then changing the program apporpriately is better.
    For ALV,refer the following links.
    For follg., refer http://www.henrikfrank.dk/abapuk.html
    http://www.sapdevelopment.co.uk/tips/tipshome.htm

  • Alv  grid : is it possible to create 2 header lines  ?

    alv  grid : is it possible to create 2 header lines  ?
    for example  :
    open year            close year
    from 2006            until   2008
    data
    data
    data
    data
    i know that i can do so in alv list  , but is it possible in alv
    grid ( with screen )   ?

    No, this is not supported by the ALV Grid control.
    Regards,
    Rich Heilman

  • Running BDC from my Editable ALV output

    Hi All,
         I want to run a bdc for my ALV output. Here the problem is the layout is editable so the values can be changed. I want to pick the values which is modified in my ALV output then using that i should run my BDC Program.
    How to catch the input given in my ALV output.
    Thank in advance.
    Arun.

    Hi, check following link:
    [https://wiki.sdn.sap.com/wiki/display/ABAP/Editable%20ALV%20through%20OOPS|https://wiki.sdn.sap.com/wiki/display/ABAP/Editable%20ALV%20through%20OOPS]

  • How to print some data in alv which is not in table.

    hi all,
    Please can any one tell me how to print some text in the existing alv program to the second line of every record.
    the header is there but it is empty.In the data,
    there are two lines printing for a normal alv.the same text should be  printed in every second line of each record.Please reply soon.its urgent.

    This is not possible in ALV.
    When you say some text I assume the text is not in the same columnar format as the list is.
    ALV supports only a columnar format (except for subtotals).
    You can add the text to the ITAB by parsing the text to the record. It is not going to look good if you do that.

  • Hi all   F4 on field in alv list

    hi all
    i would like to know how is it possible to give f4 help to a field in alv list.  this is field is input enable.
    if not in alv list, is it possible in alv grid.
    thanx
    rocky

    HI
    like this
    TYPES : BEGIN OF ST_OBJID_SH,
             OTYPE TYPE HRP1000-OTYPE,
             OBJID TYPE HRP1000-OBJID,
            END OF ST_OBJID_SH.
    DATA : IT_OBJID_SH TYPE STANDARD TABLE OF ST_OBJID_SH.
    DATA : WA_OBJID_SH TYPE ST_OBJID_SH.
    ***********SELECTION SCREEN DESIGN***********************
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    *SELECT-OPTIONS : S_OTYPE FOR HRP1001-OTYPE NO INTERVALS .
    SELECT-OPTIONS : S_OBJID FOR HRP1001-OBJID NO INTERVALS .
    SELECT-OPTIONS : DATE FOR SY-DATUM NO-EXTENSION OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    **********END OF SELECTION SCREEN DESIGN*****************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_OBJID-LOW.
    IF S_OBJID IS NOT INITIAL.
        SELECT OTYPE OBJID FROM HRP1000
                     INTO TABLE IT_OBJID_SH
                     WHERE OTYPE = 'D'.
    IF SY-SUBRC EQ 0.
    SEARCH HELP FOR QUALIFICATION.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
                 DDIC_STRUCTURE         = ' '
            RETFIELD               =  'OBJID'
                 PVALKEY                = ' '
           DYNPPROG               = SY-REPID
           DYNPNR                 = SY-DYNNR
           DYNPROFIELD            = 'S_OBJID'
                 STEPL                  = 0
                 WINDOW_TITLE           =
                 VALUE                  = ' '
           VALUE_ORG              = 'S'
                 MULTIPLE_CHOICE        = ' '
                 DISPLAY                = ' '
                 CALLBACK_PROGRAM       = ' '
                 CALLBACK_FORM          = ' '
                 MARK_TAB               =
               IMPORTING
                 USER_RESET             =
          TABLES
            VALUE_TAB              =  IT_OBJID_SH
                 FIELD_TAB              =
                 RETURN_TAB             = RETURN_TAB
                 DYNPFLD_MAPPING        =
               EXCEPTIONS
                 PARAMETER_ERROR        = 1
                 NO_VALUES_FOUND        = 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.
      ENDIF.

  • How To Add Two Heading in ALV Report

    Hello Guys,
    Currently I am Working on a report Contain 45 Column. Each 45 Column have there own heading like Days Target,Days Achieve..like this.
    Our Requirement is That
    1.Upper side of the First 10 Column one more heading required like Production  Details .
    2. From 11 to 20 One More Heading Called Furnace Oil. like that only.
    I ask users That is not possible in ALV but they are adhere to that requirement.
    Can it's is possible in ALV Grid To have a two Heading Column.
    Thanks in Advance.
    Regards
    Swati Namdev

    Hi swati,
    Normally the specified requirment is not possible with the ALV...
    But you can try with the tricky way... where you need to use the Hierarchical ALV.
    Here you need to specify the two fields in the header table for the specified headings, and you need to declare these two fields in the item table also.
    But in this case you will have one blank line on the report output(for the header data).
    Regards,
    Satya.

  • Two column header in ALV Report

    Hi Experts,
    Can I have 2 headers in ALV report kind of one header and one sub header below that.
    like i have to display a report having the same information for 3 systems so in header I can have the system name and below that
    usual headers.
    Thanks
    Yogesh Gupta

    it is is not possible using the ALV GRID function, ALV OO.
    it is possible with ALV List function. you might loose some functionalities layout etc.
    check this sample..
    cehck this image..
    http://img100.imageshack.us/img100/3846/output6ef.th.gif
    REPORT ZTEST_ALV message-id zz .
    TYPE-POOLS: SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
    IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    L_LAYOUT type slis_layout_alv,
    x_events type slis_alv_event,
    it_events type SLIS_T_EVENT.
    DATA: BEGIN OF ITAB OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    MALE type i,
    female type i,
    END OF ITAB.
    SELECT VBELN
    POSNR
    FROM VBAP
    UP TO 20 ROWS
    INTO TABLE ITAB.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-SELTEXT_L = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 1.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-SELTEXT_L = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 2.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'MALE'.
    X_FIELDCAT-SELTEXT_L = 'MALE'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 3.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'FEMALE'.
    X_FIELDCAT-SELTEXT_L = 'FEMALE'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 3.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    x_events-NAME = SLIS_EV_TOP_OF_PAGE.
    x_events-FORM = 'TOP_OF_PAGE'.
    APPEND x_events TO iT_EVENTS.
    CLEAR x_events .
    L_LAYOUT-NO_COLHEAD = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = L_LAYOUT
    IT_FIELDCAT = IT_FIELDCAT
    it_events = it_events
    TABLES
    T_OUTTAB = ITAB
    EXCEPTIONS
    PROGRAM_ERROR = 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.
    ENDIF.
    FORM TOP_OF_PAGE.
    *-To display the headers for main list
    FORMAT COLOR COL_HEADING.
    WRITE: / SY-ULINE(103).
    WRITE: / SY-VLINE,
    (8) ' ' ,
    SY-VLINE,
    (8) ' ' ,
    SY-VLINE,
    (19) '***'(015) centered,
    sy-vline.
    WRITE: / SY-VLINE,
    (8) 'VBELN'(013) ,
    SY-VLINE,
    (8) 'POSNR'(014) ,
    SY-VLINE,
    (8) 'MALE'(016) ,
    sy-vline,
    (8) 'FMALE'(017) ,
    sy-vline.
    FORMAT COLOR OFF.
    ENDFORM.

  • Create Dynamic Structure at Runtime via ALV-Methods!

    Hi Experts,
    i try to create at the ABAP Runtime a new Structure.
    FOR EXAMPLE: I have a internal Table "database" and i dont know their Structure or Typ.
    MY Question: How can i get the structuretype for this internal Table "database" ??
                                    I thought that it is possible with ALV-Methods, but i dont find the right way.
    First Step:       I must get the structure of this internal Table.
    Second Step: I must create a workarea/ line of this internal Table, that i can work row for row with the table.
    Have someone an code example for me, because iám very confused about this Problem.
    With kind regards.
    Ersin Tosun

    Hello,
    For this specific requirement, SAP has provided RTTI class.
    Below is a code snippet for your ready reference. In this example we're trying to get the structure of the dynamic table <ITAB> whose structure is not defined till run-time.
    TYPE-POOLS: abap.
    PARAMETERS: p_table TYPE tabname.
    DATA: dref TYPE REF TO data.
    FIELD-SYMBOLS <itab> TYPE STANDARD TABLE.
    CREATE DATA dref TYPE STANDARD TABLE OF (p_table).
    ASSIGN dref->* TO <itab>.
    DATA: go_tab_descr TYPE REF TO cl_abap_tabledescr,
          go_struc_descr TYPE REF TO cl_abap_structdescr,
          wa_comp TYPE abap_compdescr.
    go_tab_descr ?= cl_abap_tabledescr=>describe_by_data( <itab> ).
    CHECK sy-subrc = 0.
    go_struc_descr ?= go_tab_descr->get_table_line_type( ).
    LOOP AT go_struc_descr->components INTO wa_comp.
      WRITE: / wa_comp-name.
    ENDLOOP.
    I must create a workarea/ line of this internal Table, that i can work row for row with the table.
    Sorry i missed the Step 2:
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <wa> TYPE ANY,
                   <val> TYPE ANY.
    LOOP AT <itab> ASSIGNING <wa>.
      LOOP AT go_struc_descr->components INTO wa_comp.
    *   To access the components of the structure dynamically
        ASSIGN COMPONENT wa_comp-name OF STRUCTURE <wa> TO <val>.
      ENDLOOP.
    ENDLOOP.
    BR,
    Suhas
    Edited by: Suhas Saha on Nov 18, 2010 7:26 PM

Maybe you are looking for