SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Display Storage Unit



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 08, 2007 12:36 am    Post subject: Display Storage Unit Reply with quote

Author: Aveek Ghose

Storage Unit Display Program

Code:
REPORT  ZRGBPTPALLETDISP MESSAGE-ID ZC.

*------------------------------------------------------------------*
* TYPE POOL DECLARATION FOR ALV REPORT ONLY
*------------------------------------------------------------------*

TYPE-POOLS : slis.          "Type Pool for ALV

*------------------------------------------------------------------*
*                 SAP tables
*------------------------------------------------------------------*
TABLES:
        mseg,    " Document Segment: Material
        mkpf,    " Header: Material Document
        lein,    " Storage unit header records
        aufk,    " Order master data
        usr02,   " Logon data
        lagp,    " Storage bins
        mara,    " Material master
        mcha,    " Batches
        t156,    " Movement type
        t301.    " WM Storage Types
*------------------------------------------------------------------*
*                 CONSTANTS
*------------------------------------------------------------------*
CONSTANTS: c_a(1)  TYPE c VALUE 'A',        " value of A
           c_x(1)  TYPE c VALUE 'X',        " value of X
           c_l(1)  TYPE c VALUE 'L',        " value of L
           c_r(1)  TYPE c VALUE 'R',        " value of R
           c_h(1)  TYPE c VALUE 'H',        " value of H
           c_s(1)  TYPE c VALUE 'S',        " value of S
           c_01(2) TYPE c VALUE '01',       " value of 01
           c_02(2) TYPE c VALUE '02',       " value of 02
           c_03(2) TYPE c VALUE '03',       " value of 03
           c_04(2) TYPE c VALUE '04',       " value of 04
           c_05(2) TYPE c VALUE '05',       " value of 05
           c_06(2) TYPE c VALUE '06',       " value of 06
           c_07(2) TYPE c VALUE '07',       " value of 07
           c_08(2) TYPE c VALUE '08',       " value of 08
           c_09(2) TYPE c VALUE '09',       " value of 09
           c_10(2) TYPE c VALUE '10',       " value of 10
           c_11(2) TYPE c VALUE '11',       " value of 11
           c_12(2) TYPE c VALUE '12',       " value of 12
           c_13(2) TYPE c VALUE '13',       " value of 13
           c_14(2) TYPE c VALUE '14',       " value of 14
           c_15(2) TYPE c VALUE '15',       " value of 15
           c_16(2) TYPE c VALUE '16',       " value of 16
           c_17(2) TYPE c VALUE '17',       " value of 17
           c_18(2) TYPE c VALUE '18',       " value of 18
           c_19(2) TYPE c VALUE '19',       " value of 19
           c_20(2) TYPE c VALUE '20',       " value of 20
           c_21(2) TYPE c VALUE '21',       " value of 21
           c_22(2) TYPE c VALUE '22',       " value of 22
           c_23(2) TYPE c VALUE '23',       " value of 23
           c_24(2) TYPE c VALUE '24',       " value of 24
           c_25(2) TYPE c VALUE '25',       " value of 25
           c_26(2) TYPE c VALUE '26',       " value of 26
           c_27(2) TYPE c VALUE '27',       " value of 27
           c_28(2) TYPE c VALUE '28',       " value of 28
           c_29(2) TYPE c VALUE '29',       " value of 29
           c_30(2) TYPE c VALUE '30',       " value of 30
           c_31(2) TYPE c VALUE '31',       " value of 31
           c_32(2) TYPE c VALUE '32',       " value of 32
           c_33(2) TYPE c VALUE '33',       " value of 33
           c_34(2) TYPE c VALUE '34',       " value of 34
           c_35(2) TYPE c VALUE '35',       " value of 35
           c_36(2) TYPE c VALUE '36',       " value of 36
           c_37(2) TYPE c VALUE '37',       " value of 37
           c_38(2) TYPE c VALUE '38',       " value of 38
           c_39(2) TYPE c VALUE '39',       " value of 39
           c_40(2) TYPE c VALUE '40',       " value of 40
           c_41(2) TYPE c VALUE '41',       " value of 41
           c_42(2) TYPE c VALUE '42',       " value of 42
           c_43(2) TYPE c VALUE '43',       " value of 43
           c_44(2) TYPE c VALUE '44',       " value of 44
           c_45(2) TYPE c VALUE '45',       " value of 45
           c_46(2) TYPE c VALUE '46',       " value of 46
           c_mseg TYPE tabname VALUE 'MSEG',   " table name MSEG
           c_mkpf TYPE tabname VALUE 'MKPF',   " table name MKPF
           c_ltak TYPE tabname VALUE 'LTAK',   " table name LTAK
           c_ltap TYPE tabname VALUE 'LTAP',   " table name LTAP
           c_makt TYPE tabname VALUE 'MAKT',   " table name MAKT
           c_lein TYPE tabname VALUE 'LEIN',   " table name LEIN
           c_save_variant(1) TYPE c VALUE 'A'.   "Save Variants

*&---------------------------------------------------------------------&
*                     TYPES                                            *
*&---------------------------------------------------------------------&

* Type for declaring table I_matdoc
TYPES: BEGIN OF ty_matdoc,
        matnr TYPE matnr,
        charg TYPE charg_d,
        werks TYPE werks_d,
        lgort TYPE lgort_d,
        bwart TYPE bwart,
        sobkz TYPE sobkz,
        mblnr TYPE mblnr,
        zeile TYPE mblpo,
        budat TYPE budat,
        erfmg TYPE erfmg,
        erfme TYPE erfme,
        lgnum TYPE lgnum,
        lgtyp TYPE lgtyp,
        lgpla TYPE lgpla,
* Additional fields
        insmk TYPE insmk,
        aufpl TYPE co_aufpl,
        aufnr TYPE aufnr,
        bktxt TYPE bktxt,
        bldat TYPE bldat,
        cpudt TYPE cpudt,
        cputm TYPE cputm,
        kzbew TYPE kzbew,
        lifnr TYPE lifnr,
        meins TYPE meins,
        menge TYPE menge_d,
        mjahr TYPE mjahr,
        rsnum TYPE rsnum,
        rspos TYPE rspos,
        rsart TYPE rsart,
        shkzg TYPE shkzg,
        usnam TYPE usnam,
        vgart TYPE vgart,
        xabln TYPE xabln,
        tbnum TYPE tbnum,
        maktx TYPE maktx,
      END OF ty_matdoc,

* Type for declaring table I_matnr
      BEGIN OF ty_matnr,
        matnr TYPE matnr,
        maktx TYPE maktx,
      END OF ty_matnr,

* Type for declaring table I_mh
      BEGIN OF ty_mh,
        aufnr TYPE aufnr,
        werks TYPE werks,
        matnr TYPE matnr,
        charg TYPE charg_d,
        lgnum TYPE lgnum,
        lgpla TYPE lgpla,
        lgtyp TYPE lgtyp,
        bwart TYPE bwart,
        rsnum TYPE rsnum,
        rspos TYPE rspos,
        rsart TYPE rsart,
        lenvw TYPE t331_lenvw,
      END OF ty_mh,

* Type for declaring table I_t331
      BEGIN OF ty_t331,
        lgnum TYPE lgnum,
        lgtyp TYPE lgtyp,
        lenvw TYPE t331_lenvw,
      END OF ty_t331,

BEGIN OF TY_DETL,
         mblnr type mblnr,   " Material document no.
         mjahr type mjahr,    " Material document year
         lgnum type lgnum,   " Warehouse no.
         tanum type tanum,  " Transfer order no.
         matnr type matnr,   " Material no.
         tapos type tapos,   " Transfer order item
         bwlvs type bwlvs,   " Movement type for WM
         betyp TYPE lvs_betyp,
         benum TYPE lvs_benum,
         vltyp TYPE ltap_vltyp,
         vlpla TYPE ltap_vlpla,
         vlenr TYPE ltap_vlenr,
         nltyp TYPE ltap_nltyp,
         nlpla TYPE ltap_nlpla,
         nlenr TYPE ltap_nlenr,
         altme TYPE LRMEI,
         vsola TYPE LTAP_vsola,
         vsolm TYPE LTAP_vsolm,
         nsola TYPE LTAP_nsola,
         nsolm TYPE LTAP_nsolm,
END OF TY_DETL,


* Type for declaring table I_meins_ltap
      BEGIN OF ty_meins_ltap,
        lgnum TYPE lgnum,
        tanum TYPE tanum,
        tapos TYPE tapos,
        matnr TYPE matnr,
        meins TYPE meins,
      END OF ty_meins_ltap.
*&---------------------------------------------------------------------&
*                      STRUCTURES                                      *
*&---------------------------------------------------------------------&

*Structure to hold variant information
DATA: struct_variant TYPE disvariant.

* Workarea to hold the header line of i_matdoc
DATA: struct_matdoc TYPE ty_matdoc.

*&---------------------------------------------------------------------&
*                      INTERNAL TABLES                                 *
*&---------------------------------------------------------------------&

*Internal tables to hold material documenmt information
DATA:  i_matdoc TYPE STANDARD TABLE OF ty_matdoc WITH HEADER LINE,
       i_matdoc_distinct TYPE STANDARD TABLE OF ty_matdoc WITH HEADER
       LINE,

*Internal table to hold material description information
       i_matnr TYPE STANDARD TABLE OF ty_matnr WITH HEADER LINE,

*Internal table to hold RESB information
        i_mh TYPE STANDARD TABLE OF ty_mh WITH HEADER LINE,

*Internal table to hold T331 information
        i_t331 TYPE STANDARD TABLE OF ty_t331 WITH HEADER LINE,

*Internal table to hold detail transfer order information
       i_detl TYPE STANDARD TABLE OF ty_detl WITH HEADER LINE,

*Internal table to hold output
       i_output TYPE STANDARD TABLE OF ty_detl WITH HEADER LINE,

*Internal table for field catalog
       i_fcat TYPE slis_t_fieldcat_alv,

*Internal table for sort table
       i_sort TYPE slis_t_sortinfo_alv,  "Sort parameters

*Internal table for layout
       i_layout TYPE slis_layout_alv,

*Internal table for coloring cells
       i_col_layout TYPE slis_t_specialcol_alv,

       i_meins_ltap TYPE STANDARD TABLE OF ty_meins_ltap WITH HEADER
       LINE.

* Internal Table and Work Areas for ALV
DATA: wa_fcat TYPE slis_fieldcat_alv,
      wa_layout TYPE slis_layout_alv.

FIELD-SYMBOLS: <f_outtab> TYPE STANDARD TABLE.

*&---------------------------------------------------------------------&
*                    VARIABLES                                         *
*&---------------------------------------------------------------------&
DATA:  v_repid     LIKE sy-repid,         " To store program name
       v_title type LVC_TITLE.
*&--------------------------------------------------------------------&
*                    SELECTION SCREEN                                 *
*&--------------------------------------------------------------------&

SELECTION-SCREEN: BEGIN OF BLOCK pallet WITH FRAME TITLE text-001.
PARAMETERS:       p_plant LIKE /NESGLB/MCCNN2-WERK_PLANT
        MEMORY ID ANR OBLIGATORY .
SELECT-OPTIONS:   s_mat for mseg-matnr OBLIGATORY,    " Material No.
                  s_batch for mseg-charg OBLIGATORY,  " Batch
                  S_PRODDT for SY-DATUM,
                  S_prodTM FOR  SY-UZEIT,
*                           /NESGLB/MCCNN2-QPRODTIME,
                  s_strunt FOR lein-lenum. " Storage unit
SELECTION-SCREEN: END OF BLOCK pallet.
*&--------------------------------------------------------------------&
*                      INITIALIZATION                                 *
*&--------------------------------------------------------------------&

CLEAR:
* Internal Tables
       i_matdoc,
       i_detl,
       i_mh,
       i_t331,
       i_matnr,
       i_output,
       i_sort,
       i_fcat,
*Begin of changes Sutapa - May 26, 2003
       i_meins_ltap,
*End of changes Sutapa - May 26, 2003

* Variables
       v_repid,
       v_title.

* Refresh Internal Tables
REFRESH: i_matdoc,
         i_detl,
         i_mh,
         i_t331,
         i_matnr,
         i_output,
         i_sort,
         i_fcat,
*Begin of changes Sutapa - May 26, 2003
         i_meins_ltap.
*End of changes Sutapa - May 26, 2003

* Assign value to v_repid

v_repid = sy-repid.
*&--------------------------------------------------------------------&
*                      AT SELECTION SCREEN                            *
*&--------------------------------------------------------------------&

*Validation of Process Order
*AT SELECTION-SCREEN ON p_order.
*  PERFORM validate_order.

*Validation of Material
AT SELECTION-SCREEN ON s_mat.
  PERFORM validate_material.

*Validation of Batch
AT SELECTION-SCREEN ON s_batch.
  PERFORM validate_batch.

*Validation of Storage Unit
AT SELECTION-SCREEN ON s_strunt.
  PERFORM validate_storageunit.

*&--------------------------------------------------------------------&
*                       START OF SELECTION                            *
*&--------------------------------------------------------------------&

START-OF-SELECTION.

*&--------------------------------------------------&
* This subroutine retrieves data from MSEG and MKPF
* tables depending on the selection screen values
* and modifies the table with Material description.
*&--------------------------------------------------&
  PERFORM populate_matdoc.

*&--------------------------------------------------&
* This subroutine retrieves data from LTAK and LTAP
* tables dependingon the selection screen values and
* populates the table with Transferorder information.
*&--------------------------------------------------&
  PERFORM populate_detl.

*&--------------------------------------------------&
* This subroutine modifies anmd creates the final
* result table.
*&--------------------------------------------------&
 PERFORM create_output.      " To update I_detl

*&--------------------------------------------------------------------&
*                       END OF SELECTION                              *
*&--------------------------------------------------------------------&

END-OF-SELECTION.

* The final output is obtained by transferring the necessary fields
* from table I_DETL to I_OUTPUT.

** Check if the table I_detl is not initial
*  IF NOT i_detl[] IS INITIAL.
*    i_output[] = i_detl[].  " Get the final output
*  ENDIF.
*
** Display the Report Title
*  CONCATENATE text-003 p_order INTO v_title SEPARATED BY space.
*  sy-title =  v_title.

  PERFORM prepare_alv_settings.

* Display the Report in ALV
  PERFORM prepare_alv_output.  " To display result as alv

*&---------------------------------------------------------------------*
*&      Form  validate_material
*&---------------------------------------------------------------------*
*       This subroutine validates the value of material entered
*----------------------------------------------------------------------*
FORM validate_material .

*Check if value is entered for Material.
  IF NOT s_mat IS INITIAL.
    SELECT matnr            " Material
    INTO mara-matnr
    UP TO 1 ROWS
    FROM mara
    WHERE matnr IN s_mat.
    ENDSELECT.
    IF sy-subrc <> 0.
*     Issue error message and stop processing
      MESSAGE e999 WITH 'Invalid Material.'(097).
    ENDIF.
  ENDIF.
ENDFORM.                    " validate_material

*&---------------------------------------------------------------------*
*&      Form  validate_batch
*&---------------------------------------------------------------------*
*       This subroutine validates the value of batch entered
*----------------------------------------------------------------------*
FORM validate_batch .

*Check if value is entered for Batch.
  IF NOT s_batch IS INITIAL.
    SELECT charg           " Batch
    INTO mcha-charg
    UP TO 1 ROWS
    FROM mcha
    WHERE charg IN s_batch.
    ENDSELECT.
    IF sy-subrc <> 0.
*     Issue error message and stop processing
      MESSAGE e999 WITH 'Invalid Batch.'(098).
    ENDIF.
  ENDIF.
ENDFORM.                    " validate_batch



*&---------------------------------------------------------------------*
*&      Form  validate_storageunit
*&---------------------------------------------------------------------*
*       This subroutine validates the value of storage unit entered
*----------------------------------------------------------------------*
FORM validate_storageunit .

*Check if value is entered for storage unit.
  IF NOT s_strunt IS INITIAL.
    SELECT lenum            " storageunit
    INTO lein-lenum
    UP TO 1 ROWS
    FROM lein
    WHERE lenum IN s_strunt.
    ENDSELECT.
    IF sy-subrc <> 0.
*     Issue error message and stop processing
      MESSAGE e999 WITH 'Invalid storage unit.'(103).
    ENDIF.
  ENDIF.
ENDFORM.                    " validate_storageunit
*&---------------------------------------------------------------------*
*&      Form  populate_matdoc
*&---------------------------------------------------------------------*
* This subroutine retrieves data from MSEG and MKPF tables depending
* on the selection screen values and modifies the table with Material
* description.
*----------------------------------------------------------------------*
FORM populate_matdoc .

*Retreieve Data from MSEG and MKPF
  SELECT   a~matnr    " Material
           a~charg    " Batch
           a~werks    " Plant
           a~lgort    " Storage Location
           a~bwart    " Movement type
           a~sobkz    " Special stock indicator
           a~mblnr    " Material document no.
           a~zeile    " Item in material document
           b~budat    " Posting date
           a~erfmg    " Quantity in entry unit
           a~erfme    " Entry unit
           a~lgnum    " Warehouse no.
           a~lgtyp    " Storage type
           a~lgpla    " Storage bin
           a~insmk    " Stock type
           a~aufpl    " Routing no.
           a~aufnr    " Process order
           b~bktxt    " Document header text
           b~bldat    " Document date
           b~cpudt    " Entry date
           b~cputm    " Entry time
           a~kzbew    " Movement indicator
           a~lifnr    " Vendor
           a~meins    " Base unit of measure
           a~menge    " Base quantity
           a~mjahr    " Material document year
           a~rsnum    " Reservation no.
           a~rspos    " Reservation item
           a~rsart    " Record type
           a~shkzg    " Debit / Credit indicator
           b~usnam    " User Name
           b~vgart    " Trans. / Event type
           b~xabln    " Goods Receipt/Issue Slip Number
           a~tbnum    " Transfer Requirement Number
  INTO TABLE i_matdoc
  FROM mseg AS a INNER JOIN mkpf AS b
    ON a~mblnr = b~mblnr
    AND a~mjahr = b~mjahr
  WHERE a~matnr IN s_mat
   AND a~charg IN s_batch
   AND a~bwart IN ('101')
   AND b~budat IN s_proddt.

  IF sy-subrc <> 0.
*  Issue error message and stop processing
    MESSAGE i999 WITH 'No data found!'(104).
    LEAVE LIST-PROCESSING.
  ELSE.
*   Sort the table I_MATDOC
    SORT i_matdoc BY matnr.
*   Create a table i_matdoc_disctinct identical to i_matdoc
    i_matdoc_distinct[] = i_matdoc[].
    DELETE ADJACENT DUPLICATES FROM i_matdoc_distinct COMPARING matnr.
  ENDIF.

* Free the I_matdoc_distinct table.
  FREE I_MATDOC_DISTINCT.
ENDFORM.                    " populate_matdoc

*&---------------------------------------------------------------------*
*&      Form  populate_detl
*&---------------------------------------------------------------------*
* This subroutine retrieves data from LTAK and LTAP tables depending
* on the selection screen values and populates the table with Transfer
* order information.
*----------------------------------------------------------------------*
FORM populate_detl .

*Check if the table i_matdoc is not initial
  IF NOT i_matdoc[] IS INITIAL.

*  Retreieve Transfer Order from LTAK and LTAP
    SELECT a~mblnr    " Material document no.
           a~mjahr    " Material document year
           a~lgnum    " Warehouse no.
           a~tanum    " Transfer order no.
           b~matnr    " Material no.
           b~tapos    " Transfer order item
           a~bwlvs    " Movement type for WM
           a~betyp    " Requirement type
           a~benum    " Requirement tracking no.
           b~bestq    " Stock Category in the WM
           b~vltyp    " Source storage type
           b~vlpla    " Source storage bin
           b~vlenr    " Source storage unit
           b~nltyp    " Destination storage type
           b~nlpla    " Destination storage bin
           b~nlenr    " Destination storage unit
           b~altme
           " Alternative Unit of Measure for Stockkeeping Unit
           b~vsola    " Source target quantity in alternate unit
           b~vsolm    " Source target quantity in stockkeeping unit
           b~nsola    " Destination target quantity in alternative unit
           b~nsolm    " Destination target quantity in stockkeeping unit
    INTO CORRESPONDING FIELDS OF tABLE i_detl
    FROM ltak AS a INNER JOIN ltap AS b
    ON a~lgnum = b~lgnum
    AND a~tanum = b~tanum
    FOR ALL ENTRIES IN i_matdoc
    WHERE a~mblnr = i_matdoc-mblnr
           AND a~mjahr = i_matdoc-mjahr
           AND b~matnr = i_matdoc-matnr.
    IF sy-subrc = 0.
*     Sort the table I_DETL
      SORT i_detl BY mblnr mjahr matnr.
    ENDIF.

* Populate the value of MEINS_TO in i_detl.
*  Perform Populate_detl_meins.

  ENDIF.
ENDFORM.                    " populate_detl

*&---------------------------------------------------------------------*
*&      Form  create_output
*&---------------------------------------------------------------------*
* This subroutine modifies anmd creates the final result table.
* Depending on different conditions the i_detl table is modified to hold
* Material Document Information, Transfer Order inmformation along with
* all goods issues, goods receipts, items genearted with reference to a
*reservation and for stocks which is Storage Unit managed and
*non-storage
* unit managed.
*----------------------------------------------------------------------*
FORM create_output .

  CLEAR i_matdoc.


*&---------------------------------------------------------------------*
*&      Form  prepare_alv_output
*&---------------------------------------------------------------------*
* This subroutine preapres the ALV output
*----------------------------------------------------------------------*
FORM prepare_alv_output .

  IF NOT i_fcat[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = V_REPID
*     i_callback_user_command = 'USER_COMMAND'
*     i_callback_top_of_page  = 'TOP_OF_PAGE'
      i_structure_name        = 'I_DETL'
      i_grid_title            = V_TITLE
      is_layout               = I_layout
      it_fieldcat             = i_fcat[]
      i_save                  = c_save_variant
    TABLES
      t_outtab                = I_DETL
    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.

ENDFORM.                    " prepare_alv_output

**&---------------------------------------------------------------------
*
**&      Form  sortinfo_build
**&---------------------------------------------------------------------
*
** This subroutine builds the sort table passed to the ALV
**----------------------------------------------------------------------
*
FORM sortinfo_build .

  DATA: l_sort TYPE slis_sortinfo_alv.

* Sort criteria material number and batch
  CLEAR l_sort.
  l_sort-spos = c_01.
  l_sort-fieldname = text-004. " MATNR
  l_sort-tabname = 'I_matdoc'.
  l_sort-up = c_x.
  l_sort-subtot = c_x.
  APPEND l_sort TO i_sort.

  CLEAR l_sort.
  l_sort-spos = c_02.
  l_sort-fieldname = text-005. " CHARG
  l_sort-tabname = 'I_matdoc'.
  l_sort-up = c_x.
  APPEND l_sort TO i_sort.

ENDFORM.                    " sortinfo_build
*&---------------------------------------------------------------------

*&      Form  varinfo_build
*&---------------------------------------------------------------------

*    This subroutines builds up the variant information
*----------------------------------------------------------------------

FORM varinfo_build .

  struct_variant-report = v_repid.

ENDFORM.                    " varinfo_build
**&---------------------------------------------------------------------
*
**&      Form  layout_build
**&---------------------------------------------------------------------
*
**  This subroutine builds the layout for column optmise and color
**  display.
**----------------------------------------------------------------------
*
*
FORM layout_build USING l_layout TYPE slis_layout_alv.
  DATA :  lv_colno    TYPE i.

*  l_layout-colwidth_optimize  = 'X'.
*  l_layout-coltab_fieldname   = 'COLOR'.

*  l_layout-colwidth_optimize = 'X'.
*  l_layout-get_selinfos = 'X'.
*  l_layout-f2code = 'DETAIL'.

*  REFRESH:
*        *I_MATDOC-color,
*          i_col_layout.

*  LOOP AT i_MATDOC.
*    IF i_MATDOC-output-shkzg = c_h.
*      lv_colno = 6.       "color RED
*
*      PERFORM sub_set_color USING i_col_layout
*                                  text-013  "ERFMG
*                                  text-014  "ERFME
*                                  text-028  "MEINS
*                                  text-029  "MENGE
*                                  lv_colno.
*    ELSE.
*      lv_colno = 5.        "color GREEN
*      PERFORM sub_set_color USING i_col_layout
*                                  text-013  "ERFMG
*                                  text-014  "ERFME
*                                  text-028  "MEINS
*                                  text-029  "MENGE
*                                  lv_colno.
*    ENDIF.
*  ENDLOOP.
ENDFORM.                    " layout_build
**&---------------------------------------------------------------------
*
**&      Form  SUB_SET_COLOR
**&---------------------------------------------------------------------
*
**  This subroutine sets the colour of the Quantity and Unit of measure
**  cells depending on Debit/Credit
**----------------------------------------------------------------------
*
*
*FORM sub_set_color USING  ls_color LIKE i_col_layout
*                          p_fieldname1
*                          p_fieldname2
*                          p_fieldname3
*                          p_fieldname4
*                          p_colno.
*
*  DATA: i_lfl_color TYPE slis_specialcol_alv.
*
*  CLEAR i_lfl_color.
*  i_lfl_color-fieldname = p_fieldname1.
*  i_lfl_color-color-col = p_colno.
*  i_lfl_color-nokeycol   = 'X'.
*  APPEND i_lfl_color TO ls_color.
*
*  CLEAR i_lfl_color.
*  i_lfl_color-fieldname = p_fieldname2.
*  i_lfl_color-color-col = p_colno.
*  i_lfl_color-nokeycol   = 'X'.
*  APPEND i_lfl_color TO ls_color.
*
*  CLEAR i_lfl_color.
*  i_lfl_color-fieldname = p_fieldname3.
*  i_lfl_color-color-col = p_colno.
*  i_lfl_color-nokeycol   = 'X'.
*  APPEND i_lfl_color TO ls_color.
*
*  CLEAR i_lfl_color.
*  i_lfl_color-fieldname = p_fieldname4.
*  i_lfl_color-color-col = p_colno.
*  i_lfl_color-nokeycol   = 'X'.
*  APPEND i_lfl_color TO ls_color.
*
*ENDFORM.                    " SUB_SET_COLOR
**&---------------------------------------------------------------------
*
**&      Form  Populate_detl_meins
**&---------------------------------------------------------------------
*
**  This subroutine populates the Base Unit (MEINS) from LTAP table
** into the i_detl internal table.
**----------------------------------------------------------------------
*
*FORM Populate_detl_meins .
*
*DATA l_index type i.
*
*CLEAR l_index.
*
*  IF NOT i_detl[] IS INITIAL.
**  Retreieve BAse UNit (MEINS) from LTAP
*    SELECT a~lgnum    " Warehouse no.
*           a~tanum    " Transfer order no.
*           a~tapos    " Transfer order item
*           a~matnr    " Material no.
*           a~meins    " Base unit
*    INTO TABLE i_meins_ltap
*    FROM ltap AS a
*    FOR ALL ENTRIES IN i_detl
*    WHERE a~lgnum = i_detl-lgnum
*           AND a~tanum = i_detl-tanum
*           AND a~tapos = i_detl-tapos
*           AND a~matnr = i_detl-matnr.
*
*    l_index = 1.
*    LOOP AT i_detl.
*    CLEAR i_meins_ltap.
*    READ TABLE i_meins_ltap WITH KEY lgnum = i_detl-lgnum
*                           tanum = i_detl-tanum
*                           tapos = i_detl-tapos
*                           matnr = i_detl-matnr.
*
*    IF sy-subrc = 0.
*      i_detl-meins_to = i_meins_ltap-meins.
*      MODIFY i_detl index l_index TRANSPORTING meins_to.
*    ENDIF.
*    CLEAR i_detl.
*    l_index = l_index + 1.
*    ENDLOOP.
* ENDIF.
*
*ENDFORM.                    " Populate_detl_meins
*&---------------------------------------------------------------------*
*&      Form  prepare_alv_settings
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM prepare_alv_settings.

  PERFORM create_catalog USING:
          'MBLNR' 'Material document no',
          'MJAHR' 'Material document year',
          'LGNUM' 'Warehouse no',
          'TANUM' 'Transfer order no',
          'MATNR' 'Material no',
          'TAPOS' 'Transfer order item',
          'LWVLS' 'Movement type for WM',
          'BETYP' 'Requirement Type',
          'BENUM' 'Requirement Tracking Number',
          'BESTQ' 'Stock Category in the WM',
          'VLTYP' 'Source storage type',
          'VLPLA' 'Source storage bin',
          'VLENR' 'Source storage unit number',
          'NLTYP' 'Destination storage type',
          'NLPLA' 'Destination storage bin',
          'NLENR' 'Destination storage unit number',
          'ALTME' 'Alternative unit of measure for stockkeeping unit',
          'VSOLA' 'Source target quantity in alternate unit ',
          'VSOLM' 'Source target quantity in stockkeeping unit',
          'NSOLA' 'Destination target quantity in alternative unit',
          'NSOLM' 'Destination target quantity in stockkeeping unit'.

  i_layout-colwidth_optimize = c_x.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = V_repid
            i_internal_tabname     = 'I_DETL'
            i_inclname             = V_repid
       CHANGING
            ct_fieldcat            = i_fCAT
       EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.

ENDFORM.                    " prepare_alv_settings
*&---------------------------------------------------------------------*
*&      Form  create_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_4633   text
*      -->P_4634   text
*----------------------------------------------------------------------*
FORM create_catalog USING    value(p_i_tabfield)
                             value(p_i_colhead).

  CLEAR wa_fcat.
  wa_fcat-tabname = 'I_DETL'.
  wa_fcat-fieldname = p_i_tabfield.
  wa_fcat-seltext_l = p_i_colhead.

  APPEND wa_fcat TO i_fcat.

ENDFORM.                    " create_catalog
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.