Skip to Content
author's profile photo Former Member
Former Member

Join

Hi!

I am in the need to join two internal tables with has tables joins in it. The two sets of internal tables are for eg:- it_sel and it_sel1 and the first internal table has a table vbkd which has fplnr and the second internal table which has a table fplt has this realtion between then , ie. vbkd-fplnr = fplt-fplnr. I want to join thses two internal tables and extarct the records without missing out anything in it, I mean even if it doses not ahve avalue it should show a blank . the first iternal table has vbak, vbpa and vbkd in it and the second one has fplt and fpla tables in it. I just want to comine both to show my report output .

Can anyone help me out plz.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2008 at 07:41 PM

    Hello,

    You need to create a table with the relevant fields of the two tables.

    And then the best way to do it is doing a loop on the second table (normally items table) and then do a read table in the first table (header table).

    I suggest you to use field-symbols or reference variables to get a better performance.

    DATA:
      lt_spfli TYPE TABLE OF spfli.
    FIELD-SYMBOLS:
      <fs_splfi> LIKE LINE OF lt_spfli.
    
    LOOP AT lt_spfli ASSIGNING <fs_spfli>.
      READ TABLE lt_dependent WITH KEY... ASSIGNING <fs_dependent>.
      IF sy-subrc = 0.
       MOVE-CORRESPONDING...
       APPEND join_table.
      ENDIF.
    ENDLOOP.
    

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2008 at 07:40 PM

    do something like this..

    loop at itab1.
    write:/ itab1-field1, itab-field2.....
    
    read table itab2 with key field1 = itab-field1 field2 = itab-field2 ..<and whatever common fields are there>...
    if sy-subrc = 0.
    write: itab2-field1........
    endif.
    endloop.

    REgards,

    ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2008 at 07:41 PM

    Hi,

    Create another internal table it_final (this include it_sel & it_sel1 fields combined)

    then

    loop at it_sel.
      read table it_sel1 with key fplnr = it_sel-fplnr
      if sy-subrc eq 0.
        move sy-tabix to v_tabix.
         move-corresponding it_sel to it_final.
         move-corresponding it_sel1 to it_final.
         append it_final.
         delete it_sel1 index v_tabix.
       endif.
    endloop.
    " then move unmatch it_sel1 table entries into it_final
    loop at it_sel1 
         move-corresponding it_sel1 to it_final.
         append it_final.
     endloop.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2008 at 08:55 PM

    Hi 1

    I think that worked when I use three differnt internal tables , now I am in a differnet problem with it , when I de-bugg I can see that the rcords are comming into my final internal table finally but when I just run in my output I am not able to get the fields from the 2nd interla table , its just showing me records from the first internal table and only columns that re there in 1st internal table that only appear in my ALV report .

    Can anyone help em out plz

    though the de-bugging shows records are comming in the final internal tabel.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 03, 2008 at 03:31 PM

    Hi !

    I am in reall urgent need to do this , you all have been a great help but somehow this is not working and I am missing on lots of records when I do it this way , can anyone if you have time just have a look at my report and help m me find out the way out of it. Basically I need to combine all these tabels to display the final report with out loosing on any records , but when I do it its loosing many records , kind help will be greatly appreciated.

    *&---------------------------------------------------------------------*
    *&  Include           ZSD_RENTAL_REPTEST_T01
    *&---------------------------------------------------------------------*
    TABLES: vbak, vbap, wbrk, vbkd, fplt, fpla,  zsdsched.
    
    TYPE-POOLS: slis.
    
    DATA: BEGIN OF itab OCCURS 0,
        vbeln LIKE vbak-vbeln,              "Sales Document
        posnr LIKE vbap-posnr,              "Item
        ernam LIKE vbak-ernam,              "Created by
        erdat LIKE vbak-erdat,              "Created on
        audat LIKE vbak-audat,              "Document Date
        vbtyp LIKE vbak-vbtyp,              "SD document category
        auart LIKE vbak-auart,              "Sales Document type
        vkorg LIKE vbak-vkorg,              "Sales Org
        vtweg LIKE vbak-vtweg,              "Distribution Channel
        spart LIKE vbak-spart,              "Division
        vkbur LIKE vbak-vkbur,              "Sales Office
        guebg LIKE vbak-guebg,              "Valid from date
        gueen LIKE vbak-gueen,              "Valid to date
        kunnr LIKE vbak-kunnr,              "Sold-to party
        kunnrt LIKE kna1-name1,             "Sold-to Name
        kvgr4 LIKE vbak-kvgr4,              "Territory
        matnr LIKE vbap-matnr,              "Material
        arktx LIKE vbap-arktx,              "Material Short Text
        charg LIKE vbap-charg,              "Batch
        matkl LIKE vbap-matkl,              "Material Group
        pstyv LIKE vbap-pstyv,              "Item Category
        zmeng LIKE vbap-zmeng,              "Target Quantity
        zieme LIKE vbap-zieme,              "Target Unit
        kdmat LIKE vbap-kdmat,              "Customer Material Number
        werks LIKE vbap-werks,              "Plant
        lgort LIKE vbap-lgort,              "Storage Location
        vstel LIKE vbap-vstel,              "Shipping Point
        route LIKE vbap-route,              "Route
        netpr LIKE vbap-netpr,              "Net Price
        kpein LIKE vbap-kpein,              "Condition Price Unit
        kmein LIKE vbap-kmein,              "Condition Unit
        shkzg LIKE vbap-shkzg,              "Returns Item
        oidrc LIKE vbap-oidrc,              "DRC Code
        kunwe LIKE vbap-oid_ship,           "Ship-to
        kunwet    LIKE kna1-name1,          "Ship-to Name
        zzwprofid LIKE vbap-zzwprofid,      "Waste Profile ID
        kunre     LIKE wbrk-kunre,          "Bill-to
        kunret    LIKE kna1-name1,          "Bill-to Name
        addl_schd LIKE icon-id,             "Push Button For addl line
        datab     LIKE zsdsched-datab,      "Valid-From Date
        datbi      LIKE zsdsched-datbi,     "Valid To Date
        zschdfreq  LIKE zsdsched-zschdfreq, "Contract schedule frequency
        frequency  LIKE zsdsched-frequency, "Frequency
        monday    LIKE zsdsched-monday,     "Mondays
        tuesday   LIKE zsdsched-tuesday,    "Tuesdays
        wednesday  LIKE zsdsched-wednesday, "Wednesdays
        thursday  LIKE zsdsched-thursday,   "Thursdays
        friday    LIKE zsdsched-friday,     "Fridays
        saturday  LIKE zsdsched-saturday,   "Saturdays
        sunday    LIKE zsdsched-sunday,     "Sundays
        dzieme    LIKE zsdsched-dzieme,     "Target quantity UoM
        comments  LIKE zsdsched-comments,   "Comments
        fplnr     like vbkd-fplnr,
       END OF itab.
    
    data: begin of itab1 occurs 0,
          fksaf     LIKE fplt-fksaf,          "Billing Status
          afdat     LIKE fplt-afdat,          "Billing date
          fakwr     LIKE fplt-fakwr,          "Value to be billed
          fkdat     LIKE fplt-fkdat,          "Settelment Date
          nfdat     LIKE fplt-nfdat,          "Settelment Date
          fpart     LIKE fpla-fpart,          "Billing plan type
          bedat     LIKE fpla-bedat,          "Start day for billing
          endat     LIKE fpla-endat,          "End date for billing
          horiz     LIKE fpla-horiz,          "Horizon in billing plan
          fplnr     LIKE fplt-fplnr,
          vbeln     LIKE vbak-vbeln,
    end of itab1.
    
    data : begin of gt_report occurs 0,
        vbeln LIKE vbak-vbeln,              "Sales Document
        posnr LIKE vbap-posnr,              "Item
        ernam LIKE vbak-ernam,              "Created by
        erdat LIKE vbak-erdat,              "Created on
        audat LIKE vbak-audat,              "Document Date
        vbtyp LIKE vbak-vbtyp,              "SD document category
        auart LIKE vbak-auart,              "Sales Document type
        vkorg LIKE vbak-vkorg,              "Sales Org
        vtweg LIKE vbak-vtweg,              "Distribution Channel
        spart LIKE vbak-spart,              "Division
        vkbur LIKE vbak-vkbur,              "Sales Office
        guebg LIKE vbak-guebg,              "Valid from date
        gueen LIKE vbak-gueen,              "Valid to date
        kunnr LIKE vbak-kunnr,              "Sold-to party
        kunnrt LIKE kna1-name1,             "Sold-to Name
        kvgr4 LIKE vbak-kvgr4,              "Territory
        matnr LIKE vbap-matnr,              "Material
        arktx LIKE vbap-arktx,              "Material Short Text
        charg LIKE vbap-charg,              "Batch
        matkl LIKE vbap-matkl,              "Material Group
        pstyv LIKE vbap-pstyv,              "Item Category
        zmeng LIKE vbap-zmeng,              "Target Quantity
        zieme LIKE vbap-zieme,              "Target Unit
        kdmat LIKE vbap-kdmat,              "Customer Material Number
        werks LIKE vbap-werks,              "Plant
        lgort LIKE vbap-lgort,              "Storage Location
        vstel LIKE vbap-vstel,              "Shipping Point
        route LIKE vbap-route,              "Route
        netpr LIKE vbap-netpr,              "Net Price
        kpein LIKE vbap-kpein,              "Condition Price Unit
        kmein LIKE vbap-kmein,              "Condition Unit
        shkzg LIKE vbap-shkzg,              "Returns Item
        oidrc LIKE vbap-oidrc,              "DRC Code
        kunwe LIKE vbap-oid_ship,           "Ship-to
        aufnr LIKE vbap-aufnr,              "Interal Order #
        vkaus LIKE vbap-vkaus,              "Usage
        bezei LIKE tvlvt-bezei,             "Usage Description
        kunwet    LIKE kna1-name1,          "Ship-to Name
        zzwprofid LIKE vbap-zzwprofid,      "Waste Profile ID
        kunre     LIKE wbrk-kunre,          "Bill-to
        kunret    LIKE kna1-name1,          "Bill-to Name
        addl_schd LIKE icon-id,             "Push Button For addl line
        datab     LIKE zsdsched-datab,      "Valid-From Date
        datbi      LIKE zsdsched-datbi,     "Valid To Date
        zschdfreq  LIKE zsdsched-zschdfreq, "Contract schedule frequency
        frequency  LIKE zsdsched-frequency, "Frequency
        monday    LIKE zsdsched-monday,     "Mondays
        tuesday   LIKE zsdsched-tuesday,    "Tuesdays
        wednesday  LIKE zsdsched-wednesday, "Wednesdays
        thursday  LIKE zsdsched-thursday,   "Thursdays
        friday    LIKE zsdsched-friday,     "Fridays
        saturday  LIKE zsdsched-saturday,   "Saturdays
        sunday    LIKE zsdsched-sunday,     "Sundays
        dzieme    LIKE zsdsched-dzieme,     "Target quantity UoM
        comments  LIKE zsdsched-comments,   "Comments
        fksaf     LIKE fplt-fksaf,          "Billing Status
        afdat     LIKE fplt-afdat,          "Billing date
        fakwr     LIKE fplt-fakwr,          "Value to be billed
        fkdat     LIKE fplt-fkdat,          "Settelment Date
        nfdat     LIKE fplt-nfdat,          "Settelment Date
        fpart     LIKE fpla-fpart,          "Billing plan type
        bedat     LIKE fpla-bedat,          "Start day for billing
        endat     LIKE fpla-endat,          "End date for billing
        horiz     LIKE fpla-horiz,          "Horizon in billing plan
    
       END OF gt_report.
    
    
    DATA: gs_report    LIKE LINE OF gt_report,
          gt_sched     TYPE TABLE OF zsdsched,
          gt_sched_tmp TYPE TABLE OF zsdsched,
          gs_sched     TYPE zsdsched,
          gt_sel      LIKE gt_report OCCURS 0,
          gt_vbpa  TYPE TABLE OF vbpa,
          gs_vbpa  TYPE vbpa,
          gv_auart TYPE auart,
          gv_counter TYPE i.
    
    **-- ALV variables
    DATA: ls_fieldcat     TYPE slis_fieldcat_alv,    "Field Catalog list
          gt_fieldcat     TYPE slis_t_fieldcat_alv,  "Field Catalog
          ls_sort         TYPE slis_sortinfo_alv,    "Sorting list
          gt_sort         TYPE slis_t_sortinfo_alv,  "Sort
          gs_layout       TYPE slis_layout_alv,      "List Layout
          gs_variant      TYPE disvariant,           "Display Variant
          gv_repid         LIKE sy-repid,
          gv_save(1)           TYPE c,
          gv_exit(1)           TYPE c.
    
    CONSTANTS: gc_a     TYPE c VALUE 'A',
               gc_g     TYPE c VALUE 'G',
               gc_re(2) TYPE c VALUE 'RE'.
    
    * Screen-control Variables
    CONTROLS:
      tctrl_sched TYPE TABLEVIEW USING SCREEN 1010.     " Schedule lines.
    
    *&---------------------------------------------------------------------*
    *& Report  ZSD_RENTAL_REPTEST
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ZSD_RENTAL_REPTEST.
    *&---------------------------------------------------------------------*
    *& Report  ZSD_RENTAL_REPTEST
    *&
    *&---------------------------------------------------------------------*
    
    
    INCLUDE zsd_rental_reptest_t01.
    
    *--------------------------------------------------------------------*
    * Selection Screen
    *--------------------------------------------------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK m1 WITH FRAME TITLE text-t01.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
    SELECT-OPTIONS: s_vkorg FOR vbak-vkorg MEMORY ID vko,
                    s_vtweg FOR vbak-vtweg MEMORY ID vtw,
                    s_spart FOR vbak-spart MEMORY ID spa,
                    s_vkbur FOR vbak-vkbur MEMORY ID vkb.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln,
                    s_erdat FOR vbak-erdat,
                    s_ernam FOR vbak-ernam,
                    s_guebg FOR vbak-guebg,
                    s_gueen FOR vbak-gueen,
                    s_fplnr for fplt-fplnr,
                    s_auart FOR gv_auart MEMORY ID vta
                                         MATCHCODE OBJECT h_vakz.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS:
                    s_kunnr FOR vbak-kunnr,
                    s_kunwe FOR vbap-oid_ship,
                    s_kunre FOR wbrk-kunre.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t03.
    SELECT-OPTIONS: s_werks FOR vbap-werks MEMORY ID wrk,
                    s_lgort FOR vbap-lgort MEMORY ID lag,
                    s_vstel FOR vbap-vstel MEMORY ID vst,
                    s_route for vbap-route,
                    s_matnr FOR vbap-matnr.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t04.
    PARAMETERS:     p_varia TYPE disvariant-variant MEMORY ID wrk,
                    p_all   AS CHECKBOX DEFAULT 'X',
                    p_group AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN END OF BLOCK m1.
    
    *--------------------------------------------------------------------*
    * Start of Selection
    *--------------------------------------------------------------------*
    START-OF-SELECTION.
      PERFORM get_data.
    
    *--------------------------------------------------------------------*
    * Display ALV
    *--------------------------------------------------------------------*
    END-OF-SELECTION.
      IF gt_report[] IS INITIAL.
        MESSAGE s419(brain).
      ELSE.
        PERFORM create_alv.
      ENDIF.
    *----------------------------------------------------------------------*
    * AT SELECTION-SCREEN ON VALUE-REQUEST                                 *
    *----------------------------------------------------------------------*
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varia.
      PERFORM f01_f4_variant CHANGING p_varia.
    
    *&---------------------------------------------------------------------*
    *&      Form  get_data
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM get_data .
    data: v_tabix type sy-tabix.
    *   Select the appropriate contract data.
      SELECT a~vbeln a~erdat a~ernam a~audat a~vbtyp a~auart a~vkorg
       a~vtweg a~spart a~vkbur a~guebg a~gueen a~kunnr a~kvgr4
       b~posnr b~matnr b~charg b~matkl b~arktx b~pstyv b~zmeng
       b~zieme b~kdmat b~werks b~lgort b~vstel b~netpr b~kpein
       b~kmein b~shkzg b~oid_extbol b~oid_miscdl b~oidrc b~oid_ship AS kunwe
       b~zzwprofid c~datbi c~datab b~route d~fplnr
         INTO CORRESPONDING FIELDS OF TABLE itab
         FROM vbak AS a
             INNER JOIN vbap AS b ON a~vbeln = b~vbeln
             inner join vbkd as d on b~vbeln = d~vbeln
             LEFT OUTER JOIN zsdsched AS c ON b~vbeln = c~vbeln AND
                                   b~posnr = c~posnr
         WHERE a~vbeln IN s_vbeln
           AND a~erdat IN s_erdat
           AND a~vbtyp = gc_g
           AND a~ernam IN s_ernam
           AND a~vkorg IN s_vkorg
           AND a~vtweg IN s_vtweg
           AND a~spart IN s_spart
           AND a~vkbur IN s_vkbur
           AND a~guebg IN s_guebg
           AND a~gueen IN s_gueen
           AND a~auart IN s_auart
           AND a~kunnr IN s_kunnr
           AND b~oid_ship IN s_kunwe
           AND b~werks IN s_werks
           AND b~lgort IN s_lgort
           AND b~vstel IN s_vstel
           and b~route in s_route
           AND b~matnr IN s_matnr.
    
       SORT itab.
    *-----
    select    e~fkdat e~nfdat e~fakwr e~fksaf e~afdat
              f~fpart f~bedat f~endat f~horiz g~vbeln
              INTO CORRESPONDING FIELDS OF TABLE itab1
              FROM fplt AS e
             INNER JOIN fpla AS f ON f~fplnr = e~fplnr
             inner join vbkd as g on f~fplnr = g~fplnr
    
             where g~vbeln in s_vbeln and
                   e~fplnr in s_fplnr.
    
             sort itab1.
    
     loop at itab.
     read table itab1 with key vbeln = itab-vbeln.
     if sy-subrc = 0.
     move sy-tabix to v_tabix.
     move-corresponding itab to gt_report.
     move-corresponding itab1 to gt_report.
     append gt_report.
     delete itab1 index v_tabix.
     endif.
     endloop.
    
     loop at itab1.
     move-corresponding itab1 to gt_report.
     append gt_report.
     endloop.
    
    
    
    *----
    
    
      IF NOT itab[] IS INITIAL.
    *   Get Bill-to Party's for Item Lines
        SELECT vbeln posnr parvw kunnr INTO CORRESPONDING FIELDS OF TABLE gt_vbpa
            FROM vbpa
            FOR ALL ENTRIES IN itab
            WHERE vbeln = itab-vbeln
              AND parvw = gc_re.
    
    *   Select the remaining records from the ZSDSCHED Table.
        SELECT * FROM zsdsched
            INTO TABLE gt_sched
            FOR ALL ENTRIES IN itab
            WHERE vbeln = itab-vbeln
              AND posnr = itab-posnr.
        SORT gt_sched.
      ENDIF.
    
    * Loop through captured data for additional information
    *  LOOP AT itab INTO gs_report.
    LOOP AT itab.
    
    *   Find the bill-to party
        READ TABLE gt_vbpa INTO gs_vbpa WITH KEY vbeln = gs_report-vbeln
                                                 posnr = gs_report-posnr
                                                 parvw = gc_re.
        IF sy-subrc <> 0.
          READ TABLE gt_vbpa INTO gs_vbpa WITH KEY vbeln = gs_report-vbeln
                                                   parvw = gc_re.
          CHECK sy-subrc = 0 AND gs_vbpa-kunnr IN s_kunre.
        ELSE.
          CHECK gs_vbpa-kunnr IN s_kunre.
        ENDIF.
        gs_report-kunre = gs_vbpa-kunnr.
    
    *  Get the Customer's Name
        gs_report-kunnrt = zcl_kna1=>get_name1( itp_kunnr = gs_report-kunnr ).
        gs_report-kunwet = zcl_kna1=>get_name1( itp_kunnr = gs_report-kunwe ).
        gs_report-kunret = zcl_kna1=>get_name1( itp_kunnr = gs_report-kunre ).
    
    *   Get the scheduling lines for the item line.
        CLEAR gv_counter.
    
        IF NOT p_group IS INITIAL.
    *     If we are grouping the lines add the icon button.
          LOOP AT gt_sched INTO gs_sched WHERE vbeln = gs_report-vbeln
                                         AND posnr = gs_report-posnr.
            IF gv_counter > 0.
              gs_report-addl_schd = '@1E@'.
              CONTINUE.
            ENDIF.
            MOVE-CORRESPONDING gs_sched TO gs_report.
            ADD 1 TO gv_counter.
          ENDLOOP.
        ELSE.
    *     Otherwise get the rest of the schedule information
          READ TABLE gt_sched INTO gs_sched
            WITH KEY vbeln = gs_report-vbeln
                     posnr = gs_report-posnr
                     datbi = gs_report-datbi
                     datab = gs_report-datab.
          IF sy-subrc = 0.
            MOVE-CORRESPONDING gs_sched TO gs_report.
          ENDIF.
        ENDIF.
        APPEND gs_report TO gt_report.
      ENDLOOP.
    
    * Remove any duplicates from the reporting table
      DELETE ADJACENT DUPLICATES FROM gt_report.
    
    * If Show all records is initial, delete non-scheduled lines (ex. Sub-items)
      IF p_all IS INITIAL.
        DELETE gt_report WHERE datbi = 0
                         AND datab = 0.
      ENDIF.
    ENDFORM.                    " get_data
    *&---------------------------------------------------------------------*
    *&      Form  create_alv
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM create_alv .
      PERFORM initialize_fieldcat USING gt_fieldcat[].
      PERFORM populate_layout CHANGING gs_layout
                                       gs_variant.
      PERFORM populate_sort   USING gt_sort[].
      PERFORM display_alv_report.
    ENDFORM.                    " create_alv
    *&---------------------------------------------------------------------*
    *&      Form  initialize_fieldcat
    *&---------------------------------------------------------------------*
    *   Get and enhance the field catalog data
    *----------------------------------------------------------------------*
    *      -->L_FIELDCAT[]  text
    *----------------------------------------------------------------------*
    FORM initialize_fieldcat USING l_fieldcat TYPE slis_t_fieldcat_alv.
    
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = 'ZSD_RENTAL_REPTEST'(002)
          i_internal_tabname     = 'GT_REPORT'
          i_inclname             = 'ZSD_RENTAL_REPTEST_T01'(001)
        CHANGING
          ct_fieldcat            = l_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'VBELN'.
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Contract'.
      ls_fieldcat-hotspot     = 'X'.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'KUNNRT'.
      ls_fieldcat-seltext_s =
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Sold-to Name'.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'KUNWET'.
      ls_fieldcat-seltext_s =
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Ship-to Name'.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'KUNRET'.
      ls_fieldcat-seltext_s =
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Bill-to Name'.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'ADDL_SCHD'.
      IF NOT p_group IS INITIAL.
        ls_fieldcat-seltext_s = 'Schd'.
        ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Additional Scheduling Lines'.
        ls_fieldcat-icon = 'X'.
        CLEAR: ls_fieldcat-key,
               ls_fieldcat-ref_fieldname,
               ls_fieldcat-ref_tabname,
               ls_fieldcat-reptext_ddic,
               ls_fieldcat-ddic_outputlen.
        ls_fieldcat-hotspot     = 'X'.
        MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
      ELSE.
        DELETE l_fieldcat INDEX sy-tabix.
      ENDIF.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'DATAB'.
      ls_fieldcat-seltext_s = 'Schd From'.
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Sched. From Date'.
      CLEAR: ls_fieldcat-key.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
      READ TABLE l_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'DATBI'.
      ls_fieldcat-seltext_s = 'Schd To'.
      ls_fieldcat-seltext_m = ls_fieldcat-seltext_l = 'Sched. To Date'.
      CLEAR: ls_fieldcat-key.
      MODIFY l_fieldcat FROM ls_fieldcat INDEX sy-tabix.
    
    ENDFORM.                    " initialize_fieldcat
    *&---------------------------------------------------------------------*
    *&      Form  populate_layout
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      <--GS_LAYOUT
    *      <--GS_VARIANT
    *----------------------------------------------------------------------*
    FORM populate_layout CHANGING  gs_layout  TYPE slis_layout_alv
                                   gs_variant TYPE disvariant.
      gs_layout-colwidth_optimize = 'X'.
      gs_layout-allow_switch_to_list = 'X'.
      gs_layout-zebra                = 'X'.
    
      gs_variant-report = sy-repid.
    ENDFORM.                    " populate_layout
    *&---------------------------------------------------------------------*
    *&      Form  populate_sort
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->l_SORT[]  text
    *----------------------------------------------------------------------*
    FORM populate_sort USING l_sort TYPE slis_t_sortinfo_alv.
    
    ENDFORM.                    " populate_sort
    *&---------------------------------------------------------------------*
    *&      Form  display_alv_report
    *&---------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    FORM display_alv_report .
      gv_repid = sy-repid.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
    *     I_INTERFACE_CHECK              = ' '
    *     I_BYPASSING_BUFFER             =
    *     I_BUFFER_ACTIVE                = ' '
          i_callback_program              =  gv_repid
    *     I_CALLBACK_PF_STATUS_SET       = ' '
          i_callback_user_command        = 'USER_COMMAND'
          i_structure_name               =  'gt_report'
          is_layout                      =   gs_layout
          it_fieldcat                     =  gt_fieldcat
    *     IT_EXCLUDING                   =
    *     IT_SPECIAL_GROUPS              =
          it_sort                        =  gt_sort
    *     IT_FILTER                      =
    *     IS_SEL_HIDE                    =
          i_default                      = 'X'
          i_save                         = gc_a
          is_variant                     = gs_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
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER        =
    *     ES_EXIT_CAUSED_BY_USER         =
          TABLES
            t_outtab                       = gt_report
         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.                    " display_alv_report
    *&---------------------------------------------------------------------*
    *&      Form  f01_f4_variant
    *&---------------------------------------------------------------------*
    *    Get the Layout variant for the user.
    *----------------------------------------------------------------------*
    FORM f01_f4_variant CHANGING c_variant TYPE disvariant-variant.
    
      DATA: ls_variant TYPE disvariant,
            l_exit     TYPE char1.
    
      ls_variant-report = sy-repid.
    
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant          = ls_variant
                i_save              = 'A'
    *           it_default_fieldcat =
           IMPORTING
                e_exit              = l_exit
                es_variant          = ls_variant
           EXCEPTIONS
                not_found = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF l_exit EQ space.
          c_variant = ls_variant-variant.
        ENDIF.
      ENDIF.
    
    ENDFORM.                    " f01_f4_variant
    *------------------------------------------------------------------*
    *       FORM USER_COMMAND                                          *
    *------------------------------------------------------------------*
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    *------------------------------------------------------------------*
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
          READ TABLE gt_report INTO gs_report INDEX rs_selfield-tabindex.
          CHECK sy-subrc = 0.
          CASE rs_selfield-fieldname.
            WHEN 'VBELN'.
    *       Set parameter ID for transaction screen field
              CHECK NOT gs_report-vbeln IS INITIAL.
              SET PARAMETER ID 'KTN' FIELD gs_report-vbeln.
              CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
            WHEN 'ADDL_SCHD'.
              CHECK NOT gs_report-addl_schd IS INITIAL.
              REFRESH gt_sched_tmp.
              LOOP AT gt_sched INTO gs_sched
                               WHERE vbeln = gs_report-vbeln
                                 AND posnr = gs_report-posnr.
                APPEND gs_sched TO gt_sched_tmp.
              ENDLOOP.
              CHECK sy-subrc = 0.
              CALL SCREEN '1010' STARTING AT 5 5.
          ENDCASE.
      ENDCASE.
    ENDFORM.                    "user_command
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_1010  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE status_1010 OUTPUT.
      SET PF-STATUS 'MAIN_1010'.
      SET TITLEBAR '1010' WITH gs_report-vbeln gs_report-posnr.
    ENDMODULE.                 " STATUS_1010  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_1010  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_1010 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK' OR 'CANC'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_1010  INPUT
    *&----------------------------------------------------------------------*

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 07, 2008 at 08:08 PM

    .

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.