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

Raw Material IQA Status Inventory Report



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu Jan 21, 2010 3:29 pm    Post subject: Raw Material IQA Status Inventory Report Reply with quote

Code:
*&---------------------------------------------------------------------*
*& Company ASAT Company Limited                                        *
*&                                                                     *
*& Report  ZRMM0033                                                   *
*&                                                                     *
*& Autor:  LILO.                                                    *
*&                                                                     *
*& Date:   05.26.2005                                                  *
*&                                                                     *
*----------------------------------------------------------------------*
*& Description:                                                        *
*&   The report is used for query the raw material inventory data      *
*&                                                                     *
*----------------------------------------------------------------------*
*& Modification:
*  Mod      Resp Person      Date        Description
*
*----------------------------------------------------------------------*

REPORT zrmm0033 message-id 00.

TYPE-POOLS: slis.

*----------------------------------------------------------------------*
*  Tables                                                              *
*----------------------------------------------------------------------*
TABLES: kna1,              "Customer Master
        mcha, mchb,        "Material Batches/Stocks
        cabn, cabnt, ausp, "Characteristics/Values
        klah, ksml,        "Class Header/Characteristics
        resb,              "Reservation
        makt,              "Material Text
        aufk, afko,        "Order master/header data
        vbak, vbap,        "Sales order header/line item data
        mara, marc,
        adrc, vbpa, vbkd.  "Address, sales document partner/business dat

*----------------------------------------------------------------------*
*  Declarations                                                        *
*----------------------------------------------------------------------*
TYPES: tp_char05 TYPE char05.

DATA: BEGIN OF gt_main OCCURS 1,
        matnr LIKE mchb-matnr,              "Material
        werks LIKE mchb-werks,              "Plant
        lgort LIKE mchb-lgort,              "Storage Location
        charg LIKE mchb-charg,              "Batch
        BTREMARK(40),                         "Remark field  "DEVK903322
        ernam LIKE mchb-ernam,              "Created by
        aenam LIKE mchb-aenam,              "Changed by
        sperc LIKE mchb-sperc,              "Inventory Block
        clabs LIKE mchb-clabs,              "Unrestricted
        cumlm LIKE mchb-cumlm,              "Stock in transfer
        cinsm LIKE mchb-cinsm,              "In quanlity inspection
        ceinm LIKE mchb-ceinm,              "Restricted use
        cspem LIKE mchb-cspem,              "Blocked
        cretm LIKE mchb-cretm,              "Returns
        lwedt LIKE mcha-lwedt,              "Last GR
      END OF gt_main.

* batch classification characteristics
DATA: BEGIN OF gt_bclass OCCURS 0,
        posnr LIKE api_ch_att-posnr,        "Item No.
        atinn LIKE cabnt-atinn,             "Internal Characteristics
        atnam like api_ch_att-atnam,        "Characteristics
        atbez LIKE cabnt-atbez,             "Characteristics description
        dtype LIKE api_ch_att-dtype,        "Characteristics type
        anzdz like api_ch_att-anzdz,        "Decimal places
        atsch like api_ch_att-atsch,        "template/edit mask
        msehi like api_ch_att-msehi,        "UOM
        exist TYPE c,                       "Value exist
      END OF gt_bclass.

DATA: BEGIN OF gt_bcldat OCCURS 0,
        matnr LIKE mchb-matnr,              "Material
        werks LIKE mchb-werks,              "Plant
        lgort LIKE mchb-lgort,              "Storage Location
        charg LIKE mchb-charg,              "Batch
        atinn LIKE ausp-atinn,              "Internal Characteristics
        atwrt LIKE ausp-atwrt,              "Characteristics Value
        atflv like ausp-atflv,              "Characteristics num value
      END OF gt_bcldat.

* material classification characteristics
DATA: BEGIN OF gt_mclass OCCURS 0,
        posnr LIKE api_ch_att-posnr,        "Item No.
        atinn LIKE cabnt-atinn,             "Internal Characteristics
        atnam like api_ch_att-atnam,        "Characteristics
        atbez LIKE cabnt-atbez,             "Characteristics description
        atfor LIKE klmerka-atfor,           "Characteristics type
        anzdz like api_ch_att-anzdz,        "Decimal places
        atsch like api_ch_att-atsch,        "template/edit mask
        dimen like klmerka-dimen,           "UOM
      END OF gt_mclass.

DATA: BEGIN OF gt_mcldat OCCURS 0,
        matnr LIKE mchb-matnr,              "Material
        werks LIKE mchb-werks,              "Plant
        lgort LIKE mchb-lgort,              "Storage Location
        charg LIKE mchb-charg,              "Batch
        atnam LIKE cabn-atnam,              "Characteristics
        ausp1 LIKE ausp-atwrt,             "Characteristics description
        atflv like ausp-atflv,              "Characteristics num value
      END OF gt_mcldat.

DATA: BEGIN OF itab OCCURS 1,
*     insert fields here
        matnr LIKE mchb-matnr,              "Material
        werks LIKE mchb-werks,            "Plant
        lgort LIKE mchb-lgort,            "Storage Location
        charg LIKE mchb-charg,            "Batch
        BTREMARK(40),                       "Batch Remark DEVK903322
        ernam LIKE mchb-ernam,            "Created by
        aenam LIKE mchb-aenam,            "Changed by
        sperc LIKE mchb-sperc,            "Inventory Block
        clabs LIKE mchb-clabs,            "Unrestricted
        cumlm LIKE mchb-cumlm,            "Stock in transfer
        cinsm LIKE mchb-cinsm,            "In quanlity inspection
        ceinm LIKE mchb-ceinm,            "Restricted use
        cspem LIKE mchb-cspem,            "Blocked
        cretm LIKE mchb-cretm,            "Returns
        lwedt LIKE mcha-lwedt,            "Last GR
        meins     like mara-meins,          "UOM
        zeinr     like mara-zeinr,        "Drawing Document
        zeivr     like mara-zeivr,        "Drawing version
        licha     like mcha-licha,        "vendor batch
        hsdat     like mcha-hsdat,        "production date
        fvdt2   like mcha-fvdt2,        "mfg date
*       production order related
        xwaok LIKE resb-xwaok,            "Movement allowed
        kzear LIKE resb-kzear,            "Final issue
        bdter LIKE resb-bdter,            "Requirements date
        bdmng LIKE resb-bdmng,            "Requirements quantity
        enmng LIKE resb-enmng,            "Withdrawal quantity
        osmng LIKE resb-bdmng,            "Outstanding reqt qty
        aufnr LIKE resb-aufnr,            "Order number
        baugr LIKE resb-baugr,            "Material number(FG)
        maktx LIKE makt-maktx,            "Material text
        class LIKE sclass-class,          "Class
        kdauf LIKE aufk-kdauf,            "Sales order
        kdpos LIKE aufk-kdpos,            "Sales order item
        aprio LIKE afko-aprio,            "Order priority
        auart LIKE vbak-auart,            "Sales document type
        kunnr LIKE vbpa-kunnr,            "Bill-to party
        name1 LIKE adrc-name1,            "Customer name
        arktx LIKE vbap-arktx,            "Sales item description
        kdmat LIKE vbap-kdmat,            "Customer material
        tdlin(205) type c,          "SO item textf for fab lot#
*        tdlin LIKE tline-tdline,          "SO item textf for fab lot#
        lprio LIKE vbap-lprio,            "SO item delivery priority
        bstdk LIKE vbkd-bstdk,            "SO purchase order date
        RM_DWG LIKE AUSP-ATWRT,           " SUPPLIER DRAWING NO
        RM_NO  LIKE AUSP-ATWRT,           " ASAT DRAWING NO
      END OF itab.

*A000001
DATA: BEGIN OF gt_exp OCCURS 1,
*     die stock information
        werks LIKE mchb-werks,              "Plant
        lgort LIKE mchb-lgort,            "Storage Location
        charg LIKE mchb-charg,            "Batch
        clabs(18) type c,                   "Unrestricted
        lwedt LIKE mcha-lwedt,              "Last GR
        iqa(1) type c,
**     die characteristic information, refer to DB_DIE_CLASS
*        kunnr(10) type c,                   "Customer Code
*        name1 like kna1-name1,              "Customer Name
*        fablt(30) type c,                   "Fab Lot No.
*        wqty(8) type c,                     "Wafer Quantity
*        dqty(13) type c,                     "Die Received Quantity
      END OF gt_exp.

DATA: lin TYPE i, l(6).

data : begin of xtab1 occurs 0,
  line(1000).
data : end of xtab1.

* end of A00001

DATA: BEGIN OF con_class,
*     class type constants
*        matnr(3) VALUE '001',
        charg(3) VALUE '022',
      END OF con_class.

DATA: BEGIN OF con_char,
*     charateristic constants
*        cust(30) VALUE 'DB_CUSTOMER',
*        fl(30) VALUE 'DB_FL',
*        ICCUST(30) VALUE 'ICB_CUSTOMER',
*        ICLOT(30) VALUE 'ICB_LOT_NO',
        iqa(30) VALUE 'MM_IQA_STATUS',
      END OF con_char.

DATA: BEGIN OF con_sel,
*     selection constants
*        kunnr(3) VALUE '001',
*        fablt(3) VALUE '002',
*        ICCUST(3) VALUE '003',
*        ICLOT(3)  VALUE '004',
        IQA(3) VALUE '001',
      END OF con_sel.

DATA: BEGIN OF con_subtotal,
        st01 TYPE tp_char05 VALUE 'CLABS',
        st02 TYPE tp_char05 VALUE 'CUMLM',
        st03 TYPE tp_char05 VALUE 'CINSM',
        st04 TYPE tp_char05 VALUE 'CEINM',
        st05 TYPE tp_char05 VALUE 'CSPEM',
        st06 TYPE tp_char05 VALUE 'CRETM',
      END OF con_subtotal.

DATA: BEGIN OF con_sotxt,
        itmid(4) VALUE 'Z002',
        itmobj(4) VALUE 'VBBP',
      END OF con_sotxt.

* Report variant variables
DATA: G_REPID LIKE SY-REPID.

DATA: GX_VARIANT LIKE DISVARIANT,
      G_EXIT(1) TYPE C,
      G_SAVE(1) TYPE C,
      G_VARIANT LIKE DISVARIANT.

* Dynamic internal table variables
FIELD-SYMBOLS: <f>,
               <tab> TYPE STANDARD TABLE,
               <wa>.

DATA: intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE,
      fcat TYPE slis_t_fieldcat_alv,
      it_fieldcat TYPE lvc_t_fcat,
      g_idx TYPE i.

CONSTANTS: c_billto(2) VALUE 'RE',
*          c_maxmm TYPE i VALUE 14,  "DEVK903896
           " Value in C_MAXMM controls how many MM fields to be
           " printed out in the ALV format
           C_MAXMM TYPE I VALUE 23, "DEVK903896
           c_bcl(4) VALUE 'BCL_',
           c_mcl(4) VALUE 'MCL_'.
data atwrt1 like ausp-atwrt.


*----------------------------------------------------------------------*
*  Selection Screen                                                    *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
* Selection criteria
*PARAMETERS p_matnrz LIKE mchb-matnr.
SELECT-OPTIONS so_matnr FOR mchb-matnr.
SELECT-OPTIONS so_werks FOR mchb-werks.
SELECT-OPTIONS so_lgort FOR mchb-lgort.
SELECT-OPTIONS so_charg FOR mchb-charg.
SELECT-OPTIONS so_mtart FOR mara-mtart.
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECT-OPTIONS so_dispo FOR marc-dispo.
SELECT-OPTIONS so_licha FOR mcha-licha.
PARAMETERS p_class LIKE klah-class DEFAULT 'MM_RAWMAT' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK a.
** DB Characteristics
*SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-005.
*SELECT-OPTIONS so_kunnr FOR kna1-kunnr.
*SELECT-OPTIONS so_fablt FOR ausp-atwrt.
*SELECTION-SCREEN END OF BLOCK d.
** ICB Characteristics
*SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-006.
*SELECT-OPTIONS IC_CUST  FOR KNA1-KUNNR.       "DEVK903322
*SELECT-OPTIONS IC_LOT   FOR AUSP-ATWRT.       "DEVK903322
*SELECTION-SCREEN END OF BLOCK e.
* Raw Material Characteristics
SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-007.
SELECT-OPTIONS so_iqa FOR ausp-atwrt.
SELECTION-SCREEN END OF BLOCK d.
* Variant
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-003.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK 0.
* Layout
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (20) text-011
                 FOR FIELD p_nozero.
SELECTION-SCREEN POSITION pos_low.
PARAMETERS p_nozero AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (20) text-012
                 FOR FIELD p_ppincl.
SELECTION-SCREEN POSITION pos_low.
PARAMETERS p_ppincl AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
" START OF DEVK903322
PARAMETERS P_NOMISS   AS CHECKBOX.
PARAMETERS P_NOEMPT   AS CHECKBOX.
" END OF DEVK903322
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (20) text-013 FOR FIELD p_nodisp.
PARAMETERS p_nodisp TYPE c NO-DISPLAY.
SELECTION-SCREEN END OF LINE.
PARAMETERS p_werksl AS CHECKBOX DEFAULT 'X'.
PARAMETERS p_lgortl AS CHECKBOX DEFAULT 'X'.
PARAMETERS p_chargl AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b.

* A00001
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-004.
parameters : p_cbexp type c as checkbox.
parameters : p_fname1 like rlgrap-filename MODIF ID MG2, " obligatory
             p_fname2 like rlgrap-filename MODIF ID MG2. " obligatory
SELECTION-SCREEN END OF BLOCK c.

* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
  PERFORM F4_FOR_VARIANT.

* A00001
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname1 .
  perform F4_VALUE_FNAME1.

* PAI
AT SELECTION-SCREEN.
  PERFORM PAI_OF_SELECTION_SCREEN.
  perform check_file.

*AT SELECTION-SCREEN ON so_kunnr.
*  PERFORM check_so_value USING con_sel-kunnr.
*
*AT SELECTION-SCREEN ON END OF so_kunnr.
*  PERFORM check_so_value USING con_sel-kunnr.
*
*AT SELECTION-SCREEN ON so_fablt.
*  PERFORM check_so_value USING con_sel-fablt.
*
*AT SELECTION-SCREEN ON END OF so_fablt.
*  PERFORM check_so_value USING con_sel-fablt.
*
AT SELECTION-SCREEN ON so_iqa.
  PERFORM check_so_value USING con_sel-iqa.

AT SELECTION-SCREEN ON END OF so_iqa.
  PERFORM check_so_value USING con_sel-iqa.

* START OF DEVK903322
*AT SELECTION-SCREEN ON IC_CUST.
*  PERFORM CHECK_SO_VALUE USING CON_SEL-KUNNR.
*
*AT SELECTION-SCREEN ON END OF IC_CUST.
*  PERFORM CHECK_SO_VALUE USING CON_SEL-KUNNR.
*
*AT SELECTION-SCREEN ON IC_LOT.
*  PERFORM CHECK_SO_VALUE USING CON_SEL-ICLOT.
*
*AT SELECTION-SCREEN ON END OF IC_LOT.
*  PERFORM CHECK_SO_VALUE USING CON_SEL-ICLOT.
* END OF DEVK903322

AT SELECTION-SCREEN ON p_werksl.
  IF p_werksl IS INITIAL.
    IF p_lgortl = 'X'.
      MESSAGE w899(mm)
        WITH 'Stock at higher levels will also be displayed.'.
      p_werksl = 'X'.
    ENDIF.
  ENDIF.

AT SELECTION-SCREEN ON p_lgortl.
  IF p_lgortl IS INITIAL.
    IF p_chargl = 'X'.
      MESSAGE w899(mm)
        WITH 'Stock at higher levels will also be displayed.'.
      p_lgortl = 'X'.
    ENDIF.
  ENDIF.


*----------------------------------------------------------------------*
*  Initialization                                                      *
*----------------------------------------------------------------------*
INITIALIZATION.
  G_REPID = SY-REPID.

* Set Options: save variants userspecific or general
  G_SAVE = 'A'.
  PERFORM VARIANT_INIT.
* Get default variant
  GX_VARIANT = G_VARIANT.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
       EXPORTING
            I_SAVE     = G_SAVE
       CHANGING
            CS_VARIANT = GX_VARIANT
       EXCEPTIONS
            NOT_FOUND  = 2.
  IF SY-SUBRC = 0.
    P_VARI = GX_VARIANT-VARIANT.
  ENDIF.

*----------------------------------------------------------------------*
*  Start of Selection                                                  *
*----------------------------------------------------------------------*
START-OF-SELECTION.

* IF p_matnrz IS INITIAL.
* IF SO_MATNR[] IS INITIAL and SO_LGORT[] IS INITIAL.
*   MESSAGE s899(mm)
*     WITH 'Please enter material and/or storage location!'.
*   EXIT.
* ENDIF.

* insert code to fill ITAB here :)
  PERFORM select_records.
  IF P_NOMISS = 'X'.
    DELETE ITAB WHERE BTREMARK = 'Missing'.
  ENDIF.
  IF P_NOEMPT = 'X'.
    DELETE ITAB WHERE BTREMARK = 'Empty'.
  ENDIF.
  DELETE ITAB WHERE BTREMARK = 'Skip'.

END-OF-SELECTION.

  DESCRIBE TABLE itab LINES lin.
  WRITE lin TO l.

  if p_cbexp = 'X'.
    perform collect_dieinfo.
    perform format_file.
    if p_fname1 is initial.
      perform download_serv.
    else.
      perform download_pc.
    endif.
  else.
    PERFORM outputalv.
  endif.

*******************************************************

*----------------------------------------------------------------------*
*  Subroutine                                                          *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  initialization
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM initialization .
ENDFORM.                    " initialization
*&---------------------------------------------------------------------*
*&      Form  OutputALV
*&---------------------------------------------------------------------*
*       Purpose: Set and display ALV grids
*----------------------------------------------------------------------*
FORM outputalv.

  DATA: fieldcat TYPE slis_t_fieldcat_alv,
        fc_str   TYPE slis_fieldcat_alv,
        layout   TYPE slis_layout_alv,
        title    TYPE lvc_title,
        repid    LIKE sy-repid,
        variant  LIKE disvariant,
        sort     TYPE slis_t_sortinfo_alv,
        sort_str TYPE slis_sortinfo_alv
        .

  repid = sy-repid.

  layout-colwidth_optimize = 'X'.

*  variant-report = repid.

*   create dynamic table
  PERFORM build-field-cat.
  PERFORM create-data-table.
  PERFORM fill-data-table.

  title = sy-title.

* SORTING OPTIONS
  sort_str-spos = 1.
  sort_str-fieldname = 'MATNR'.
  sort_str-up = 'X'.
  sort_str-subtot = 'X'. " calc subtotals by this
  IF p_werksl IS INITIAL.
    sort_str-expa = 'X'.   " collapse to subtotals
  ENDIF.
  APPEND sort_str TO sort.
  sort_str-spos = 2.
  sort_str-fieldname = 'WERKS'.
*  sort_str-down = 'X'.
  sort_str-up = 'X'.
  sort_str-subtot = 'X'. " calc subtotals by this
  IF p_lgortl IS INITIAL.
    sort_str-expa = 'X'.   " collapse to subtotals
  ENDIF.
  APPEND sort_str TO sort.
  sort_str-spos = 3.
  sort_str-fieldname = 'LGORT'.
  sort_str-up = 'X'.
  sort_str-subtot = 'X'. " calc subtotals by this
  IF p_chargl IS INITIAL.
    sort_str-expa = 'X'.   " collapse to subtotals
  ENDIF.
  APPEND sort_str TO sort.

* display ALV
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_grid_title = title
     it_fieldcat  = fcat[]            "REPLACED fieldcat
     is_layout    = layout
     i_save       = G_SAVE            "'A'
     is_variant   = G_VARIANT         "variant
     it_sort        = sort
*     I_CALLBACK_PROGRAM      = repid
*     I_CALLBACK_USER_COMMAND = 'OUTPUTALV_DETAILS'
   TABLES
     t_outtab    = <tab>              "REPLACED itab
   EXCEPTIONS
     program_error = 1
     OTHERS        = 2
  .


ENDFORM.                    "OutputALV

*******************************************************

*FORM OutputALV_Details USING in_ucomm LIKE sy-ucomm
*                             in_selfield TYPE SLIS_SELFIELD.
*
* get the info from line selected
*  READ TABLE itab INDEX in_selfield-tabindex.
*
**  REFRESH det_tab.
*
*
*  SORT det_tab BY .
*
*ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  select_records
*&---------------------------------------------------------------------*
*       Purpose:  Select records from tables by selection criteria
*----------------------------------------------------------------------*
*      -->P_ATWRT  text
*----------------------------------------------------------------------*

FORM select_records.

  DATA: l_token TYPE c,
        l_tabix LIKE sy-tabix.
  data: xmatnr like mara-matnr.
* get table data
  if so_matnr[] is initial.
     if so_charg[] is initial.
        SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_main FROM mchb
        WHERE werks IN so_werks
          AND lgort IN so_lgort AND charg IN so_charg.
     else.
        SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_main FROM mchb
        WHERE werks IN so_werks AND charg IN so_charg
          AND lgort IN so_lgort.
     endif.
  else.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_main FROM mchb
    WHERE matnr IN SO_matnr AND werks IN so_werks
    AND lgort IN so_lgort AND charg IN so_charg.
  endif.
*  delete gt_main where
*         sperc = 0 and clabs = 0 and
*         cumlm = 0 and cinsm = 0 and
*         ceinm = 0 and cspem = 0 and
*         cretm = 0.


  LOOP AT gt_main.
    select single matnr into xmatnr from mara
      where matnr = gt_main-matnr
        and mtart in so_mtart
        and matkl in so_matkl.
    check sy-subrc = 0.
    select single matnr into xmatnr from marc
      where matnr = gt_main-matnr
        and werks = gt_main-werks
        and dispo in so_dispo.
    check sy-subrc = 0.
    SELECT SINGLE lwedt INTO gt_main-lwedt
      FROM mcha WHERE matnr = gt_main-matnr AND werks = gt_main-werks
      AND charg = gt_main-charg.
       PERFORM check_batch_value USING l_token.
       " START OF DEVK903322
*      CHECK l_token IS INITIAL.
       IF L_TOKEN = 'X'.
         GT_MAIN-BTREMARK = 'Empty'.
       ELSEIF L_TOKEN = 'Y'.
         GT_MAIN-BTREMARK = 'Missing'.
       ELSEIF L_TOKEN = 'Z'.
         GT_MAIN-BTREMARK = 'Others'.
       ELSEIF L_TOKEN = 'N'.           "Characteristics not found
         GT_MAIN-BTREMARK = 'Skip'.
       ELSEIF L_TOKEN = ' '.
         GT_MAIN-BTREMARK = 'OK'.
*        EXIT.                             "DEVK903601
       ENDIF.
       check l_token = ' '.
    " END OF DEVK903322
****************************************

       clear atwrt1.
       select single ausp~atwrt into (atwrt1)
                  from ausp join cabn on ausp~atinn = cabn~atinn
                  where objek = gt_main-matnr
                       and klart = '001'
                       and cabn~atnam = 'RM_SUP_DWG_NUM'.

       itab-rm_dwg = atwrt1.
       clear atwrt1.
       select single ausp~atwrt into (atwrt1)
                  from ausp join cabn on ausp~atinn = cabn~atinn
                  where objek = gt_main-matnr
                       and klart = '001'
                       and cabn~atnam = 'RM_DRAWING_NO'.
*
*       SELECT SINGLE * FROM AUSP WHERE OBJEK = BATAB-MATNR
*                            AND KLART = '001'
*                            AND ATINN = 'RM_DRAWING_NO'.

       itab-rm_no = atwrt1.

****************************************

    select single * from mcha where matnr = gt_main-matnr
                                and werks = gt_main-werks
                                and charg = gt_main-charg.
    check mcha-licha in so_licha.
    move: mcha-licha to itab-licha,
          mcha-hsdat to itab-hsdat,
          mcha-fvdt2 to itab-fvdt2.
    select single * from mara where matnr = gt_main-matnr.
    move: mara-meins to itab-meins,
          mara-zeinr to itab-zeinr,
          mara-zeivr to itab-zeivr.
    MOVE-CORRESPONDING gt_main TO itab.
    IF p_nozero = 'X'.
      IF ( gt_main-clabs = 0 AND gt_main-cumlm = 0
              AND gt_main-cinsm = 0 AND gt_main-ceinm = 0
              AND gt_main-cspem = 0 AND gt_main-cretm = 0 ).
        DELETE gt_bcldat
          WHERE werks = gt_main-werks AND ( lgort = gt_main-lgort )
            AND ( charg = gt_main-charg ).
        CHECK p_nozero IS INITIAL.
      ENDIF.
    ENDIF.
    IF p_ppincl = 'X'.
      PERFORM pp_details USING gt_main-matnr gt_main-werks
                               gt_main-lgort gt_main-charg.
      sort gt_mclass by posnr.
    ELSE.
      APPEND itab.
      CLEAR itab.
    ENDIF.
  ENDLOOP.

  SORT gt_bclass BY posnr.
  LOOP AT gt_bclass.
    l_tabix = sy-tabix.
    READ TABLE gt_bcldat WITH KEY atinn = gt_bclass-atinn.
    IF sy-subrc = 0.
      gt_bclass-exist = 'X'.
      MODIFY gt_bclass INDEX l_tabix TRANSPORTING exist.
    ENDIF.
  ENDLOOP.

ENDFORM.                              " select_records
*&---------------------------------------------------------------------*
*&      Form  check_so_value
*&---------------------------------------------------------------------*
*       Purpose:  check select-option whether it is within batches
*----------------------------------------------------------------------*
*      -->P_ATWRT  text
*----------------------------------------------------------------------*
FORM check_so_value  USING    p_atwrt.

  DATA: l_count TYPE i.
  DATA: lt_ausp LIKE ausp OCCURS 0 WITH HEADER LINE.
  DATA: l_atwrt LIKE ausp-atwrt.
  DATA: l_mesg(80) TYPE c.
  DATA: lt_so LIKE bbpf4b OCCURS 0 WITH HEADER LINE.

  CASE p_atwrt.
*    WHEN con_sel-kunnr.
*      LOOP AT so_kunnr.
*        MOVE-CORRESPONDING so_kunnr TO lt_so.
*        APPEND lt_so.
*        CLEAR lt_so.
*      ENDLOOP.
*      PERFORM check_class_value TABLES lt_so
*                                USING con_char-cust.
*
*    WHEN con_sel-fablt.
*      LOOP AT so_fablt.
*        MOVE-CORRESPONDING so_fablt TO lt_so.
*        APPEND lt_so.
*        CLEAR lt_so.
*      ENDLOOP.
*      PERFORM check_class_value TABLES lt_so
*                                USING con_char-fl.
*    " START OF DEVK903322
*    WHEN CON_SEL-ICLOT.
*      LOOP AT IC_LOT.
*        MOVE-CORRESPONDING IC_LOT TO LT_SO.
*        APPEND LT_SO.
*        CLEAR  LT_SO.
*      ENDLOOP.
*      PERFORM CHECK_CLASS_VALUE TABLES LT_SO
*                                USING CON_CHAR-ICLOT.
*    " END OF DEVK903322
    WHEN con_sel-iqa.
      LOOP AT so_iqa.
        MOVE-CORRESPONDING so_iqa TO lt_so.
        APPEND lt_so.
        CLEAR lt_so.
      ENDLOOP.
      PERFORM check_class_value TABLES lt_so
                                USING con_char-iqa.
    WHEN OTHERS.

  ENDCASE.

ENDFORM.                    " check_so_value
*&---------------------------------------------------------------------*
*&      Form  get_charval
*&---------------------------------------------------------------------*
*       Purpoase:  Get characteristic values by characteristic
*                  name(p_char) and class(p_class), and store the values
*                  into table(p_ausp)
*----------------------------------------------------------------------*
*      -->P_CHAR  text
*      -->P_CLASS  text
*      -->P_AUSP  text
*----------------------------------------------------------------------*
FORM get_charval  TABLES   p_ausp
                  USING    p_char LIKE cabn-atnam
                           p_class LIKE ausp-klart
                           p_charn LIKE cabnt-atbez.

  SELECT SINGLE atinn INTO cabn-atinn FROM cabn
    WHERE atnam = p_char.
  SELECT SINGLE atbez INTO p_charn FROM cabnt
    WHERE atinn = cabn-atinn.
  SELECT * INTO TABLE p_ausp FROM ausp
    WHERE atinn = cabn-atinn AND klart = p_class.

ENDFORM.                    " get_charval
*&---------------------------------------------------------------------*
*&      Form  check_class_value
*&---------------------------------------------------------------------*
*       Purpose:  Check classification values in select-options
*----------------------------------------------------------------------*
*      -->P_SO  text
*----------------------------------------------------------------------*
FORM check_class_value  TABLES   p_so STRUCTURE bbpf4b
                        USING    p_char.

  DATA: l_count TYPE i.
  DATA: lt_ausp LIKE ausp OCCURS 0 WITH HEADER LINE.
  DATA: l_atwrt LIKE ausp-atwrt.
  DATA: l_mesg(80) TYPE c,
        l_subrc LIKE sy-subrc.
  DATA: l_desc LIKE cabnt-atbez.

  DESCRIBE TABLE p_so LINES l_count.
  IF l_count > 0.
    PERFORM get_charval TABLES lt_ausp
                        USING p_char con_class-charg l_desc.
    IF l_count = 1.
      READ TABLE p_so INDEX 1.
*     Single value
      IF p_so-option = 'EQ'.
        READ TABLE lt_ausp WITH KEY atwrt = p_so-low.
        l_subrc = sy-subrc.
        l_atwrt = p_so-low.
      ENDIF.
*     Multiple values check low and high
      IF p_so-option = 'BT'.
        READ TABLE lt_ausp WITH KEY atwrt = p_so-low.
        IF sy-subrc = 0.
          READ TABLE lt_ausp WITH KEY atwrt = p_so-high.
          l_atwrt = p_so-high.
        ELSE.
          l_atwrt = p_so-low.
        ENDIF.
        l_subrc = sy-subrc.
      ENDIF.
    ELSE.
      LOOP AT p_so.
*       Single value
        IF p_so-option = 'EQ'.
          READ TABLE lt_ausp WITH KEY atwrt = p_so-low.
          IF sy-subrc NE 0.
            l_atwrt = p_so-low.
            l_subrc = sy-subrc.
            EXIT.
          ENDIF.
        ENDIF.
*       Multiple values check low and high
        IF p_so-option = 'BT'.
          READ TABLE lt_ausp WITH KEY atwrt = p_so-low.
          IF sy-subrc = 0.
            READ TABLE lt_ausp WITH KEY atwrt = p_so-high.
            IF sy-subrc NE 0.
              l_atwrt = p_so-high.
              l_subrc = sy-subrc.
              EXIT.
            ENDIF.
          ELSE.
            l_atwrt = p_so-low.
            l_subrc = sy-subrc.
            EXIT.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
    IF l_subrc NE 0.
      CONCATENATE l_desc l_atwrt 'does not exist!!'
        INTO l_mesg SEPARATED BY space.
      MESSAGE e899(mm)
        WITH l_mesg.
    ENDIF.
  ENDIF.

ENDFORM.                    " check_class_value
*&---------------------------------------------------------------------*
*&      Form  check_batch_value
*&---------------------------------------------------------------------*
*       Purpose: Check batch value if it is chosen in select-options
*----------------------------------------------------------------------*
*      -->P_TOKEN  text
*----------------------------------------------------------------------*

FORM check_batch_value  USING    p_token.

  DATA: l_check TYPE i.
  DATA: l_count TYPE i.
  DATA: lt_ausp LIKE ausp OCCURS 0.
  DATA: lt_val LIKE api_vali OCCURS 0 WITH HEADER LINE,
        lt_char LIKE api_char OCCURS 0 WITH HEADER LINE,
        lt_att LIKE api_ch_att OCCURS 0 WITH HEADER LINE.
  DATA: wa_val LIKE api_vali.

  CLEAR p_token.

*  READ TABLE gt_bclass INDEX 1.
*  IF sy-subrc = 0.
*    CALL FUNCTION 'QC01_BATCH_VALUES_READ'
*      EXPORTING
*        i_val_matnr    = gt_main-matnr
*        i_val_werks    = gt_main-werks
*        i_val_charge   = gt_main-charg
*      TABLES
*        t_val_tab      = lt_val
*      EXCEPTIONS
*        no_class       = 1
*        internal_error = 2
*        no_values      = 3
*        no_chars       = 4
*        OTHERS         = 5.
*  ELSE.
    CALL FUNCTION 'QC01_BATCH_VALUES_READ'
      EXPORTING
        i_val_matnr          = gt_main-matnr
        i_val_werks          = gt_main-werks
        i_val_charge         = gt_main-charg
*       I_LANGUAGE           = SY-LANGU
*       I_DATE               = SY-DATUM
*     IMPORTING
*       E_CLASS              =
*       E_CLASS_TYPE         =
      TABLES
        t_val_tab            = lt_val
        t_char_tab           = lt_char
        t_att_tab            = lt_att
      EXCEPTIONS
        no_class             = 1
        internal_error       = 2
        no_values            = 3
        no_chars             = 4
        OTHERS               = 5
              .
*  ENDIF.

  IF sy-subrc = 0.
*   get batch classification
    LOOP AT lt_att.
      read table gt_bclass with key atinn = lt_att-atinn.
      if sy-subrc <> 0.
         MOVE-CORRESPONDING lt_att TO gt_bclass.
         APPEND gt_bclass.
      endif.
    ENDLOOP.

*    DESCRIBE TABLE SO_FABLT LINES lin.     "DEVK903601
*    IF LIN > 0.                            "DEVK903601
*      read table lt_val with key atnam = con_char-fl.
*      if sy-subrc = 0.
*        LOOP AT lt_val
*          WHERE atnam = con_char-fl
*            AND atwrt IN so_fablt.
*          l_check = 1.
*          CHECK l_check IS INITIAL.
*        ENDLOOP.
*        IF l_check IS INITIAL.
*          p_token = 'N'.
*          EXIT.
*        ENDIF.
*      endif.
*    ENDIF.                                  "DEVK903601
*    CLEAR l_check.
*    DESCRIBE TABLE SO_KUNNR LINES lin.      "DEVK903601
*    IF LIN > 0.                             "DEVK903601
*      read table lt_val with key atnam = con_char-cust.
*      if sy-subrc = 0.
*        LOOP AT lt_val
*          WHERE atnam = con_char-cust
*            AND atwrt IN so_kunnr.
*          l_check = 1.
*          CHECK l_check IS INITIAL.
*        ENDLOOP.
*        IF l_check IS INITIAL.
*          p_token = 'N'.
*          EXIT.
*        ENDIF.
*      endif.
*    ENDIF.                                   "DEVK903601
*    CLEAR l_check.
*    "" START OF DEVK903322
*    DESCRIBE TABLE IC_CUST LINES lin.       "DEVK903601
*    IF LIN > 0.                              "DEVK903601
*      READ TABLE LT_VAL WITH KEY ATNAM = CON_CHAR-ICCUST.
*      IF SY-SUBRC = 0.
*        LOOP AT LT_VAL
*          WHERE ATNAM = CON_CHAR-ICCUST
*            AND ATWRT IN IC_CUST.
*          L_CHECK = 1.
*          CHECK L_CHECK IS INITIAL.
*        ENDLOOP.
*        IF L_CHECK IS INITIAL.
*          P_TOKEN = 'N'.
*          EXIT.
*        ENDIF.
*      ENDIF.
*    ENDIF.                                    "DEVK903601
*    CLEAR l_check.
*    DESCRIBE TABLE IC_LOT LINES lin.          "DEVK903601
*    IF LIN > 0.                               "DEVK903601
*      READ TABLE LT_VAL WITH KEY ATNAM = CON_CHAR-ICLOT.
*      IF SY-SUBRC = 0.
*        LOOP AT LT_VAL
*          WHERE ATNAM = CON_CHAR-ICLOT
*            AND ATWRT IN IC_LOT.
*          L_CHECK = 1.
*          CHECK L_CHECK IS INITIAL.
*        ENDLOOP.
*        IF L_CHECK IS INITIAL.
*          P_TOKEN = 'N'.
*          EXIT.
*        ENDIF.
*      ENDIF.
*    ENDIF.                                     "DEVK903601
*    "" END OF DEVK903322
    DESCRIBE TABLE SO_iqa LINES lin.     "DEVK903601
    IF LIN > 0.                            "DEVK903601
      read table lt_val with key atnam = con_char-iqa.
      if sy-subrc = 0.
        LOOP AT lt_val
          WHERE atnam = con_char-iqa
            AND atwrt IN so_iqa.
          l_check = 1.
          CHECK l_check IS INITIAL.
        ENDLOOP.
        IF l_check IS INITIAL.
          p_token = 'N'.
          EXIT.
        ENDIF.
      else.
        p_token = 'N'.
        EXIT.
      endif.
    ENDIF.                                  "DEVK903601
    LOOP AT lt_val.
      MOVE-CORRESPONDING gt_main TO gt_bcldat.
      MOVE-CORRESPONDING lt_val TO gt_bcldat.
      APPEND gt_bcldat.
      CLEAR gt_bcldat.
    ENDLOOP.
  ELSE.
    IF SY-SUBRC = '3'.     "Batch characteristics exist but empty
      p_token = 'X'.
    ELSEIF SY-SUBRC = '2'. "Batch characteristics does not exist
      P_TOKEN = 'Y'.
    ELSE.
      P_TOKEN = 'Z'.
    ENDIF.
  ENDIF.
ENDFORM.                    " check_batch_value

*&---------------------------------------------------------------------*
*&      Form  pp_details
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_MATNR  text
*      -->P_WERKS  text
*      -->P_LGORT  text
*      -->P_CHARG  text
*----------------------------------------------------------------------*
FORM pp_details  USING    p_matnr
                          p_werks
                          p_lgort
                          p_charg.

  DATA: lt_class LIKE sclass OCCURS 0 WITH HEADER LINE,
        lt_clobjdat LIKE clobjdat OCCURS 0 WITH HEADER LINE.
  DATA: l_tname LIKE thead-tdname,
        l_tdobj LIKE thead-tdobject.
  DATA: lt_tline LIKE tline OCCURS 0 WITH HEADER LINE.
  DATA: l_objek LIKE ausp-objek.
  DATA: lt_features like KLMERKA occurs 0 with header line.
  DATA: wa_tab like itab.
  DATA: l_tdata(40).
  DATA: l_token type i.

  move-corresponding itab to wa_tab.
* get reservation details
  SELECT * FROM resb
    WHERE matnr = p_matnr AND werks = p_werks
      AND charg = p_charg.

    MOVE-CORRESPONDING WA_TAB TO ITAB.

    MOVE: resb-xwaok TO itab-xwaok,
          resb-kzear TO itab-kzear,
          resb-bdter TO itab-bdter,
          resb-bdmng TO itab-bdmng,
          resb-enmng TO itab-enmng,
          resb-aufnr TO itab-aufnr,
          resb-baugr TO itab-baugr.
    itab-osmng = resb-bdmng - resb-enmng.
*   get device details, the material classification
    SELECT SINGLE maktx INTO itab-maktx FROM makt
      WHERE matnr = resb-baugr AND spras = sy-langu.
    l_objek = resb-baugr.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
      EXPORTING
        classtype          = '001' "con_class-matnr
        object             = l_objek
      TABLES
        t_class            = lt_class
        t_objectdata       = lt_clobjdat
      EXCEPTIONS
        no_classification  = 1
        no_classtypes      = 2
        invalid_class_type = 3
        OTHERS             = 4.
    IF sy-subrc = 0.
      READ TABLE lt_class INDEX 1.
      MOVE lt_class-class TO itab-class.
      LOOP AT lt_clobjdat.
*       check if a new characteristic exists
        READ TABLE gt_mclass WITH KEY atnam = lt_clobjdat-atnam.
        IF sy-subrc NE 0.
          CALL FUNCTION 'CLME_FEATURE_ATTR_OF_CLASS'
            EXPORTING
              class                 = itab-class
              classtype             = '001' "con_class-matnr
            tables
              tfeatures             = lt_features
            EXCEPTIONS
             CLASS_NOT_FOUND       = 1
             NO_AUTHORITY          = 2
             OTHERS                = 3
                    .
          IF sy-subrc = 0.
            read table lt_features with key lt_clobjdat-atnam.
            check sy-subrc = 0.
            move lt_clobjdat-posnr to gt_mclass-posnr.
            move-corresponding lt_features to gt_mclass.
            append gt_mclass.
          ENDIF.
        ENDIF.
        MOVE-CORRESPONDING gt_main TO gt_mcldat.
        MOVE-CORRESPONDING lt_clobjdat TO gt_mcldat.
        APPEND gt_mcldat.
      ENDLOOP.
    ENDIF.
*   get order details
    SELECT SINGLE aprio INTO itab-aprio FROM afko
      WHERE aufnr = resb-aufnr.
    SELECT SINGLE kdauf kdpos INTO (itab-kdauf,itab-kdpos) FROM aufk
      WHERE aufnr = resb-aufnr.
*   get sales order details
    IF sy-subrc = 0.
      SELECT SINGLE auart INTO itab-auart FROM vbak
        WHERE vbeln = itab-kdauf.
      SELECT SINGLE * FROM vbpa
        WHERE vbeln = itab-kdauf AND posnr = itab-kdpos
        AND parvw = c_billto.
      IF sy-subrc = 0.
        MOVE vbpa-kunnr TO itab-kunnr.
        SELECT SINGLE name1 INTO itab-name1 FROM adrc
          WHERE addrnumber = vbpa-adrnr.
      ELSE.
        SELECT SINGLE * FROM vbpa
          WHERE vbeln = itab-kdauf AND parvw = c_billto.
        MOVE vbpa-kunnr TO itab-kunnr.
        SELECT SINGLE name1 INTO itab-name1 FROM adrc
          WHERE addrnumber = vbpa-adrnr.
      ENDIF.
      SELECT SINGLE arktx kdmat lprio
        INTO (itab-arktx,itab-kdmat,itab-lprio) FROM vbap
        WHERE vbeln = itab-kdauf AND posnr = itab-kdpos.
      SELECT SINGLE bstdk INTO itab-bstdk FROM vbkd
        WHERE vbeln = itab-kdauf AND posnr = itab-kdpos.
      CONCATENATE itab-kdauf itab-kdpos INTO l_tname.
      l_tdobj = con_sotxt-itmobj.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          id                      = con_sotxt-itmid
          language                = sy-langu
          name                    = l_tname
          object                  = l_tdobj
        TABLES
          lines                   = lt_tline
        EXCEPTIONS
          id                      = 1
          language                = 2
          name                    = 3
          not_found               = 4
          object                  = 5
          reference_check         = 6
          wrong_access_to_archive = 7
          OTHERS                  = 8.
      IF sy-subrc = 0.
        loop at lt_tline.
          l_tdata = lt_tline-tdline.
          if itab-tdlin is initial.
            itab-tdlin = l_tdata.
          else.
            concatenate itab-tdlin l_tdata into itab-tdlin
              separated by '/'.
          endif.
          if sy-index = 5.
            exit.
          endif.
        endloop.
*       change for multiple texts 26.11.2003
*        READ TABLE lt_tline INDEX 1.
*        MOVE lt_tline-tdline TO itab-tdlin.
      ENDIF.

    ENDIF.

    l_token = 1.
    APPEND ITAB.
    CLEAR ITAB.
  ENDSELECT.
  if l_token is initial.
    APPEND ITAB.
    CLEAR ITAB.
  endif.

ENDFORM.                    " pp_details
Back to top
View user's profile Send private message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu Jan 21, 2010 3:30 pm    Post subject: Reply with quote

Code:
*&---------------------------------------------------------------------*
*&      Form  BUILD-FIELD-CAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build-field-cat .

  CLEAR g_idx.
  PERFORM build-mm-fields.
  PERFORM build-bcl-fields.
  PERFORM build-pp-fields.
  PERFORM build-mcl-fields.

ENDFORM.                    " BUILD-FIELD-CAT
*&---------------------------------------------------------------------*
*&      Form  BUILD-MM-FIELDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build-mm-fields .

  DATA: is_fieldcat LIKE LINE OF it_fieldcat,
        wcat LIKE LINE OF fcat.

  DO c_maxmm TIMES.
    g_idx = g_idx + 1.         "global index to track down the table col
    is_fieldcat-col_pos = g_idx.
    CASE sy-index.
      WHEN 01.
        is_fieldcat-fieldname = 'MATNR'.
        is_fieldcat-ref_field = 'MATNR'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 02.
        is_fieldcat-fieldname = 'WERKS'.
        is_fieldcat-ref_field = 'WERKS'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 03.
        is_fieldcat-fieldname = 'LGORT'.
        is_fieldcat-ref_field = 'LGORT'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 04.
        is_fieldcat-fieldname = 'CHARG'.
        is_fieldcat-ref_field = 'CHARG'.
        is_fieldcat-ref_table = 'MCHB'.

      " START OF DEVK903322
      WHEN 05.
        IS_FIELDCAT-FIELDNAME = 'BTREMARK'.
        IS_FIELDCAT-REF_FIELD = ''.
        IS_FIELDCAT-REF_TABLE = ''.
      " END OF DEVK903322
*start 001
        is_fieldcat-inttype = 'C'.
        is_fieldcat-intlen = 20.

        is_fieldcat-scrtext_l = 'BTREMARK'.
        is_fieldcat-scrtext_s = 'BTREMARK'.
        is_fieldcat-seltext = is_fieldcat-scrtext_l .

        wcat-seltext_l = is_fieldcat-scrtext_l.
        wcat-seltext_s = is_fieldcat-scrtext_s.
*end 001

      WHEN 06.
        is_fieldcat-fieldname = 'ERNAM'.
        is_fieldcat-ref_field = 'ERNAM'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 07.
        is_fieldcat-fieldname = 'AENAM'.
        is_fieldcat-ref_field = 'AENAM'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 08.
        is_fieldcat-fieldname = 'SPERC'.
        is_fieldcat-ref_field = 'SPERC'.
        is_fieldcat-ref_table = 'MCHB'.

      WHEN 09.
        is_fieldcat-fieldname = 'CLABS'.
        is_fieldcat-ref_field = 'CLABS'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 10.
        is_fieldcat-fieldname = 'CUMLM'.
        is_fieldcat-ref_field = 'CUMLM'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 11.
        is_fieldcat-fieldname = 'CINSM'.
        is_fieldcat-ref_field = 'CINSM'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 12.
        is_fieldcat-fieldname = 'CEINM'.
        is_fieldcat-ref_field = 'CEINM'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 13.
        is_fieldcat-fieldname = 'CSPEM'.
        is_fieldcat-ref_field = 'CSPEM'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 14.
        is_fieldcat-fieldname = 'CRETM'.
        is_fieldcat-ref_field = 'CRETM'.
        is_fieldcat-ref_table = 'MCHB'.
        wcat-do_sum = 'X'.

      WHEN 15.
        is_fieldcat-fieldname = 'LWEDT'.
        is_fieldcat-ref_field = 'LWEDT'.
        is_fieldcat-ref_table = 'MCHA'.

      WHEN 16.
        is_fieldcat-fieldname = 'MEINS'.
        is_fieldcat-ref_field = 'MEINS'.
        is_fieldcat-ref_table = 'MARA'.

      WHEN 17.
        is_fieldcat-fieldname = 'ZEINR'.
        is_fieldcat-ref_field = 'ZEINR'.
        is_fieldcat-ref_table = 'MARA'.

      WHEN 18.
        is_fieldcat-fieldname = 'ZEIVR'.
        is_fieldcat-ref_field = 'ZEIVR'.
        is_fieldcat-ref_table = 'MARA'.

      WHEN 19.
        is_fieldcat-fieldname = 'LICHA'.
        is_fieldcat-ref_field = 'LICHA'.
        is_fieldcat-ref_table = 'MCHA'.

      WHEN 20.
        is_fieldcat-fieldname = 'HSDAT'.
        is_fieldcat-ref_field = 'HSDAT'.
        is_fieldcat-ref_table = 'MCHA'.

      WHEN 21.
        is_fieldcat-fieldname = 'FVDT2'.
        is_fieldcat-ref_field = 'FVDT2'.
        is_fieldcat-ref_table = 'MCHA'.
      WHEN 22.
        is_fieldcat-fieldname = 'RM_DWG'.
*        is_fieldcat-ref_field = 'ATWRT'.
*        is_fieldcat-ref_table = 'AUSP'.
        is_fieldcat-inttype = 'C'.
        is_fieldcat-intlen = 30.
        is_fieldcat-scrtext_l = 'Supplier Drawing NO'.
        is_fieldcat-scrtext_s = 'Supplier Drawing NO'.
        is_fieldcat-seltext = is_fieldcat-scrtext_l .

        wcat-seltext_l = is_fieldcat-scrtext_l.
        wcat-seltext_s = is_fieldcat-scrtext_s.

      WHEN 23.
        is_fieldcat-fieldname = 'RM_NO'.
*        is_fieldcat-ref_field = 'ATWRT'.
*        is_fieldcat-ref_table = 'AUSP'.
        is_fieldcat-inttype = 'C'.
        is_fieldcat-intlen = 30.

        is_fieldcat-scrtext_l = 'Asat Drawing NO'.
        is_fieldcat-scrtext_s = 'Asat Drawing NO'.
        is_fieldcat-seltext = is_fieldcat-scrtext_l .

        wcat-seltext_l = is_fieldcat-scrtext_l.
        wcat-seltext_s = is_fieldcat-scrtext_s.

    ENDCASE.
    APPEND is_fieldcat TO it_fieldcat.
* field catalog for alv grid
    wcat-col_pos = is_fieldcat-col_pos.
    wcat-fieldname = is_fieldcat-fieldname.
    wcat-ref_tabname = is_fieldcat-ref_table.
    wcat-ref_fieldname = is_fieldcat-ref_field.
    APPEND wcat TO fcat.
    CLEAR: is_fieldcat, wcat.
  ENDDO.

ENDFORM.                    " BUILD-MM-FIELDS
*&---------------------------------------------------------------------*
*&      Form  BUILD-PP-FIELDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build-pp-fields .

  DATA: is_fieldcat LIKE LINE OF it_fieldcat,
        wcat LIKE LINE OF fcat.

  DO 21 TIMES.
    g_idx = g_idx + 1.        "global index to track down the table col
    is_fieldcat-col_pos = g_idx.
    CASE sy-index.
      WHEN 1.
        is_fieldcat-fieldname = 'XWAOK'.
        is_fieldcat-ref_field = 'XWAOK'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 2.
        is_fieldcat-fieldname = 'KZEAR'.
        is_fieldcat-ref_field = 'KZEAR'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 3.
        is_fieldcat-fieldname = 'BDTER'.
        is_fieldcat-ref_field = 'BDTER'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 4.
        is_fieldcat-fieldname = 'BDMNG'.
        is_fieldcat-ref_field = 'BDMNG'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 5.
        is_fieldcat-fieldname = 'ENMNG'.
        is_fieldcat-ref_field = 'ENMNG'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 6.
        is_fieldcat-fieldname = 'OSMNG'.
        is_fieldcat-ref_field = 'ENMNG'.
        is_fieldcat-ref_table = 'RESB'.
        is_fieldcat-scrtext_l = 'Outstanding Reqmt Quantity'.
        is_fieldcat-scrtext_s = 'OS Req. Qty'.
        wcat-seltext_l = is_fieldcat-scrtext_l.
        wcat-seltext_s = is_fieldcat-scrtext_s.

      WHEN 7.
        is_fieldcat-fieldname = 'AUFNR'.
        is_fieldcat-ref_field = 'AUFNR'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 8.
        is_fieldcat-fieldname = 'KDAUF'.
        is_fieldcat-ref_field = 'KDAUF'.
        is_fieldcat-ref_table = 'AUFK'.

      WHEN 9.
        is_fieldcat-fieldname = 'KDPOS'.
        is_fieldcat-ref_field = 'KDPOS'.
        is_fieldcat-ref_table = 'AUFK'.

      WHEN 10.
        is_fieldcat-fieldname = 'APRIO'.
        is_fieldcat-ref_field = 'APRIO'.
        is_fieldcat-ref_table = 'AFKO'.

      WHEN 11.
        is_fieldcat-fieldname = 'AUART'.
        is_fieldcat-ref_field = 'AUART'.
        is_fieldcat-ref_table = 'VBAK'.

      WHEN 12.
        is_fieldcat-fieldname = 'KUNNR'.
        is_fieldcat-ref_field = 'KUNNR'.
        is_fieldcat-ref_table = 'VBPA'.

      WHEN 13.
        is_fieldcat-fieldname = 'NAME1'.
        is_fieldcat-ref_field = 'NAME1'.
        is_fieldcat-ref_table = 'ADRC'.

      WHEN 14.
        is_fieldcat-fieldname = 'ARKTX'.
        is_fieldcat-ref_field = 'ARKTX'.
        is_fieldcat-ref_table = 'VBAP'.

      WHEN 15.
        is_fieldcat-fieldname = 'KDMAT'.
        is_fieldcat-ref_field = 'KDMAT'.
        is_fieldcat-ref_table = 'VBAP'.

      WHEN 16.
        is_fieldcat-fieldname = 'TDLIN'.
        is_fieldcat-inttype = 'C'.
        is_fieldcat-intlen = '210'.
        is_fieldcat-scrtext_l = 'Fabrication Lot No'.
        is_fieldcat-scrtext_s = 'Fab Lot#'.
        wcat-seltext_l = is_fieldcat-scrtext_l.
        wcat-seltext_s = is_fieldcat-scrtext_s.

      WHEN 17.
        is_fieldcat-fieldname = 'LPRIO'.
        is_fieldcat-ref_field = 'LPRIO'.
        is_fieldcat-ref_table = 'VBAP'.

      WHEN 18.
        is_fieldcat-fieldname = 'BSTDK'.
        is_fieldcat-ref_field = 'BSTDK'.
        is_fieldcat-ref_table = 'VBKD'.

      WHEN 19.
        is_fieldcat-fieldname = 'BAUGR'.
        is_fieldcat-ref_field = 'BAUGR'.
        is_fieldcat-ref_table = 'RESB'.

      WHEN 20.
        is_fieldcat-fieldname = 'MAKTX'.
        is_fieldcat-ref_field = 'MAKTX'.
        is_fieldcat-ref_table = 'MAKT'.

      WHEN 21.
        is_fieldcat-fieldname = 'CLASS'.
        is_fieldcat-ref_field = 'CLASS'.
        is_fieldcat-ref_table = 'SCLASS'.

    ENDCASE.
    APPEND is_fieldcat TO it_fieldcat.
* field catalog for alv grid
    IF p_ppincl IS INITIAL.
      wcat-no_out = 'X'.
    ENDIF.
    wcat-col_pos = is_fieldcat-col_pos.
    wcat-fieldname = is_fieldcat-fieldname.
    wcat-ref_tabname = is_fieldcat-ref_table.
    wcat-ref_fieldname = is_fieldcat-ref_field.
    APPEND wcat TO fcat.
    CLEAR: is_fieldcat, wcat.
  ENDDO.

ENDFORM.                    " BUILD-PP-FIELDS
*&---------------------------------------------------------------------*
*&      Form  CREATE-DATA-TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create-data-table .
  DATA: new_table TYPE REF TO data,
        new_line  TYPE REF TO data.
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fieldcat
    IMPORTING
      ep_table        = new_table.
  ASSIGN new_table->* TO <tab>.
  CREATE DATA new_line LIKE LINE OF <tab>.
  ASSIGN new_line->* TO <wa>.
ENDFORM.                    " CREATE-DATA-TABLE
*&---------------------------------------------------------------------*
*&      Form  FILL-DATA-TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM fill-data-table .
  FIELD-SYMBOLS: <fs_field> TYPE ANY.
  DATA: l_idx(3) TYPE n,
        l_field(8).

  CLEAR <wa>.
  LOOP AT itab.
*   Fill MM details
    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-matnr.
    ASSIGN COMPONENT 'WERKS' OF STRUCTURE <wa> TO <f>.
    <f> = itab-werks.
    ASSIGN COMPONENT 'LGORT' OF STRUCTURE <wa> TO <f>.
    <f> = itab-lgort.
    ASSIGN COMPONENT 'CHARG' OF STRUCTURE <wa> TO <f>.
    <f> = itab-charg.
    " START OF DEVK903322
    ASSIGN COMPONENT 'BTREMARK' OF STRUCTURE <WA> TO <F>.
    <F> = ITAB-BTREMARK.
    " END OF DEVK903322
    ASSIGN COMPONENT 'ERNAM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-ernam.
    ASSIGN COMPONENT 'AENAM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-aenam.
    ASSIGN COMPONENT 'SPERC' OF STRUCTURE <wa> TO <f>.
    <f> = itab-sperc.
    ASSIGN COMPONENT 'CLABS' OF STRUCTURE <wa> TO <f>.
    <f> = itab-clabs.
    ASSIGN COMPONENT 'CUMLM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-cumlm.
    ASSIGN COMPONENT 'CINSM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-cinsm.
    ASSIGN COMPONENT 'CEINM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-ceinm.
    ASSIGN COMPONENT 'CSPEM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-cspem.
    ASSIGN COMPONENT 'CRETM' OF STRUCTURE <wa> TO <f>.
    <f> = itab-cretm.
    ASSIGN COMPONENT 'LWEDT' OF STRUCTURE <wa> TO <f>.
    <f> = itab-lwedt.
    ASSIGN COMPONENT 'MEINS' OF STRUCTURE <wa> TO <f>.
    <f> = itab-meins.
    ASSIGN COMPONENT 'ZEINR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-zeinr.
    ASSIGN COMPONENT 'ZEIVR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-zeivr.
    ASSIGN COMPONENT 'LICHA' OF STRUCTURE <wa> TO <f>.
    <f> = itab-licha.
    ASSIGN COMPONENT 'HSDAT' OF STRUCTURE <wa> TO <f>.
    <f> = itab-hsdat.
    ASSIGN COMPONENT 'FVDT2' OF STRUCTURE <wa> TO <f>.
    <f> = itab-fvdt2.
****************************************************
    ASSIGN COMPONENT 'RM_DWG' OF STRUCTURE <wa> TO <f>.
    <f> = itab-RM_DWG.
    ASSIGN COMPONENT 'RM_NO' OF STRUCTURE <wa> TO <f>.
    <f> = itab-RM_NO.


******************************************************
*   Fill batch classification details
    LOOP AT gt_bclass.
      l_idx = sy-tabix.
      CONCATENATE c_bcl l_idx INTO l_field.
      ASSIGN COMPONENT l_field OF STRUCTURE <wa> TO <f>.
      READ TABLE gt_bcldat WITH KEY werks = itab-werks
        lgort = itab-lgort charg = itab-charg atinn = gt_bclass-atinn.
      IF sy-subrc = 0.
        if gt_bclass-dtype = 'NUM'.
          <f> = gt_bcldat-atflv.
        else.
          <f> = gt_bcldat-atwrt.
        endif.
      ENDIF.
    ENDLOOP.
*   Fill PP details
    ASSIGN COMPONENT 'XWAOK' OF STRUCTURE <wa> TO <f>.
    <f> = itab-xwaok.
    ASSIGN COMPONENT 'KZEAR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kzear.
    ASSIGN COMPONENT 'KZEAR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kzear.
    ASSIGN COMPONENT 'BDTER' OF STRUCTURE <wa> TO <f>.
    <f> = itab-bdter.
    ASSIGN COMPONENT 'BDMNG' OF STRUCTURE <wa> TO <f>.
    <f> = itab-bdmng.
    ASSIGN COMPONENT 'ENMNG' OF STRUCTURE <wa> TO <f>.
    <f> = itab-enmng.
    ASSIGN COMPONENT 'OSMNG' OF STRUCTURE <wa> TO <f>.
    <f> = itab-osmng.
    ASSIGN COMPONENT 'AUFNR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-aufnr.
    ASSIGN COMPONENT 'BAUGR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-baugr.
    ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <wa> TO <f>.
    <f> = itab-maktx.
    ASSIGN COMPONENT 'CLASS' OF STRUCTURE <wa> TO <f>.
    <f> = itab-class.
    ASSIGN COMPONENT 'KDAUF' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kdauf.
    ASSIGN COMPONENT 'KDPOS' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kdpos.
    ASSIGN COMPONENT 'APRIO' OF STRUCTURE <wa> TO <f>.
    <f> = itab-aprio.
    ASSIGN COMPONENT 'AUART' OF STRUCTURE <wa> TO <f>.
    <f> = itab-auart.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kunnr.
    ASSIGN COMPONENT 'NAME1' OF STRUCTURE <wa> TO <f>.
    <f> = itab-name1.
    ASSIGN COMPONENT 'ARKTX' OF STRUCTURE <wa> TO <f>.
    <f> = itab-arktx.
    ASSIGN COMPONENT 'KDMAT' OF STRUCTURE <wa> TO <f>.
    <f> = itab-kdmat.
    ASSIGN COMPONENT 'TDLIN' OF STRUCTURE <wa> TO <f>.
    <f> = itab-tdlin.
    ASSIGN COMPONENT 'LPRIO' OF STRUCTURE <wa> TO <f>.
    <f> = itab-lprio.
    ASSIGN COMPONENT 'BSTDK' OF STRUCTURE <wa> TO <f>.
    <f> = itab-bstdk.
*   Fill material classification details
    LOOP AT gt_mclass.
      l_idx = sy-tabix.
      CONCATENATE c_mcl l_idx INTO l_field.
      ASSIGN COMPONENT l_field OF STRUCTURE <wa> TO <f>.
      READ TABLE gt_mcldat WITH KEY werks = itab-werks
        lgort = itab-lgort charg = itab-charg atnam = gt_mclass-atnam.
      IF sy-subrc = 0.
        if gt_mclass-atfor = 'NUM'.
          <f> = gt_mcldat-atflv.
        else.
          <f> = gt_mcldat-ausp1.
        endif.
      ENDIF.
    ENDLOOP.
    APPEND <wa> TO <tab>.
    CLEAR <wa>.
  ENDLOOP.

ENDFORM.                    " FILL-DATA-TABLE
*&---------------------------------------------------------------------*
*&      Form  BUILD-BCL-FIELDS
*&---------------------------------------------------------------------*
*       Purpose: Builds up the field structure for batch classification
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build-bcl-fields .

  DATA: is_fieldcat LIKE LINE OF it_fieldcat,
        wcat LIKE LINE OF fcat.
*        l_index(3) TYPE n.

  LOOP AT gt_bclass.
    g_idx = g_idx + 1.        "global index to track down the table col
    is_fieldcat-col_pos = g_idx.
* generic field name
    CONCATENATE c_bcl gt_bclass-posnr INTO is_fieldcat-fieldname.
* field formats
    if gt_bclass-dtype = 'NUM'.
      is_fieldcat-inttype = 'P'.
      move: gt_bclass-atsch to is_fieldcat-EDIT_MASK,
            gt_bclass-anzdz to is_fieldcat-DECIMALS,
            gt_bclass-msehi to is_fieldcat-QUANTITY,
            is_fieldcat-fieldname to is_fieldcat-DECMLFIELD.
*     check if field is quantity
      find 'qty' in gt_bclass-atnam ignoring case.
      if sy-subrc = 0.
        wcat-do_sum = 'X'.
      endif.
    else.
      is_fieldcat-inttype = 'C'.
      is_fieldcat-intlen = '30'.
    endif.
    is_fieldcat-seltext = gt_bclass-atbez.
    APPEND is_fieldcat TO it_fieldcat.
* field catalog for alv grid
    IF gt_bclass-exist IS INITIAL.
      wcat-no_out = 'X'.
    ENDIF.
    wcat-col_pos = is_fieldcat-col_pos.
    wcat-fieldname = is_fieldcat-fieldname.
    wcat-seltext_l = is_fieldcat-seltext.
    APPEND wcat TO fcat.
    CLEAR: is_fieldcat, wcat.
  ENDLOOP.

ENDFORM.                    " BUILD-BCL-FIELDS
*&---------------------------------------------------------------------*
*&      Form  BUILD-MCL-FIELDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build-mcl-fields .

  DATA: is_fieldcat LIKE LINE OF it_fieldcat,
        l_idx(3) type n,
        wcat LIKE LINE OF fcat.

  LOOP AT gt_mclass.
    g_idx = g_idx + 1.        "global index to track down the table col
    is_fieldcat-col_pos = g_idx.
* generic field name
*    CONCATENATE c_mcl gt_mclass-posnr INTO is_fieldcat-fieldname.
    l_idx = sy-tabix.
    CONCATENATE c_mcl l_idx INTO is_fieldcat-fieldname.
* field formats
    if gt_mclass-atfor = 'NUM'.
      is_fieldcat-inttype = 'P'.
      move: gt_mclass-atsch to is_fieldcat-EDIT_MASK,
            gt_mclass-anzdz to is_fieldcat-DECIMALS,
            gt_mclass-dimen(3) to is_fieldcat-QUANTITY,
            is_fieldcat-fieldname to is_fieldcat-DECMLFIELD.
*     check if field is quantity
      find 'qty' in gt_mclass-atnam ignoring case.
      if sy-subrc = 0.
        wcat-do_sum = 'X'.
      endif.
    else.
      is_fieldcat-inttype = 'C'.
      is_fieldcat-intlen = '30'.
    endif.
    is_fieldcat-seltext = gt_mclass-atbez.
    APPEND is_fieldcat TO it_fieldcat.
* field catalog for alv grid
    IF p_ppincl IS INITIAL.
      wcat-no_out = 'X'.
    ENDIF.
    wcat-col_pos = is_fieldcat-col_pos.
    wcat-fieldname = is_fieldcat-fieldname.
    wcat-seltext_l = is_fieldcat-seltext.
    APPEND wcat TO fcat.
    CLEAR: is_fieldcat, wcat.
  ENDLOOP.

ENDFORM.                    " BUILD-MCL-FIELDS
*&---------------------------------------------------------------------*
*&      Form  VARIANT_INIT
*&---------------------------------------------------------------------*
*       Purpose: Initialize variants
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form VARIANT_INIT .
  CLEAR G_VARIANT.
  G_VARIANT-REPORT = G_REPID.
endform.                    " VARIANT_INIT
*&---------------------------------------------------------------------*
*&      Form  F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*       Purpose: Search variants request
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form F4_FOR_VARIANT .
*
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
       EXPORTING
            IS_VARIANT          = G_VARIANT
            I_SAVE              = G_SAVE
*           it_default_fieldcat =
       IMPORTING
            E_EXIT              = G_EXIT
            ES_VARIANT          = GX_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 G_EXIT = SPACE.
      P_VARI = GX_VARIANT-VARIANT.
    ENDIF.
  ENDIF.
endform.                    " F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*&      Form  PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*       Purpose: Check selection values
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form PAI_OF_SELECTION_SCREEN .
*
  IF NOT P_VARI IS INITIAL.
    MOVE G_VARIANT TO GX_VARIANT.
    MOVE P_VARI TO GX_VARIANT-VARIANT.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
         EXPORTING
              I_SAVE     = G_SAVE
         CHANGING
              CS_VARIANT = GX_VARIANT.
    G_VARIANT = GX_VARIANT.
  ELSE.
    PERFORM VARIANT_INIT.
  ENDIF.

endform.                    " PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*&      Form  F4_VALUE_FNAME1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form F4_VALUE_FNAME1 .
DATA: l_path       LIKE dxfields-longpath ,                     "NAD_50A
      l_abend_flag LIKE dxfields-abendflag.                     "NAD_50A

  l_path = p_fname1.
  CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
       EXPORTING
            i_location_flag       = 'P'
            i_server              = ' '
            i_path                = l_path
       IMPORTING
            o_path                = l_path
            abend_flag            = l_abend_flag
       EXCEPTIONS
            communication_failure = 1
            system_failure        = 2
            rfc_error             = 3.
  IF sy-subrc EQ 0.
    p_fname1 = l_path.
  ENDIF.

endform.                    " F4_VALUE_FNAME1
*&---------------------------------------------------------------------*
*&      Form  check_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form check_file .

  if p_fname1 ne space.
    if p_fname2 ne space.
      message e001 with ' Please enter either PC files or server files'.
    endif.
  endif.

endform.                    " check_file
*&---------------------------------------------------------------------*
*&      Form  collect_dieinfo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form collect_dieinfo .

data: begin of lt_kna1 occurs 0,
        kunnr like kna1-kunnr,
        name1 like kna1-kunnr,
      end of lt_kna1.

  select * into corresponding fields of table lt_kna1 from kna1.

  loop at itab
* M000001
    where lgort ne 'DWIP'.
    gt_exp-werks = itab-werks.
    gt_exp-lgort = itab-lgort.
    gt_exp-charg = itab-charg.
    gt_exp-clabs = itab-clabs.
    gt_exp-lwedt = itab-lwedt.
    LOOP AT gt_bclass.
      READ TABLE gt_bcldat WITH KEY werks = itab-werks
        lgort = itab-lgort charg = itab-charg atinn = gt_bclass-atinn.
      IF sy-subrc = 0.
        case gt_bclass-atnam.
*          when 'DB_CUSTOMER'.
*            gt_exp-kunnr = gt_bcldat-atwrt.
*
*          when 'DB_FL'.
*            gt_exp-fablt = gt_bcldat-atwrt.
*
*          when 'DB_WQTY'.
*            gt_exp-wqty = gt_bcldat-atwrt.
*
*          when 'DB_DQTY'.
*            gt_exp-dqty = gt_bcldat-atwrt.
          when 'MM_IQA_STATUS'.
            gt_exp-iqa = gt_bcldat-atwrt.
          when others.
        endcase.
      ENDIF.
    ENDLOOP.

*    if gt_exp-kunnr is initial.
*      if not so_kunnr is initial.
*        clear gt_exp.
*        continue.
*      endif.
*    else.
*      read table lt_kna1 with key kunnr = gt_exp-kunnr.
*      gt_exp-name1 = lt_kna1-name1.
*    endif.

    append gt_exp.
    clear gt_exp.
  endloop.

endform.                    " collect_dieinfo
*&---------------------------------------------------------------------*
*&      Form  format_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form format_file .

data: l_grdate(10).

* M000001
*  concatenate 'Plant' 'SLoc' 'Received Date' 'Batch' 'Customer#'
*              'Customer' 'Fab lot no.' 'Wafer Qty' 'Received Qty'
*              'Current Qty' 'Remark' into xtab1 separated by ','.
  concatenate 'Plant' 'SLoc' 'Received Date' 'Batch' 'Customer#'
              'Customer' 'Fab lot no.' 'Wafer Qty' 'Received Qty'
              'Current Qty' into xtab1 separated by ','.
  append xtab1.
  clear xtab1.

  loop at gt_exp.
    if not gt_exp-lwedt is initial.
      concatenate gt_exp-lwedt+4(2) gt_exp-lwedt+6(2) gt_exp-lwedt(4)
                  into l_grdate separated by '/'.
    endif.
    concatenate '"' gt_exp-werks '"' ','
                '"' gt_exp-lgort '"' ','
                '"' l_grdate '"' ','
                '"' gt_exp-charg '"' ','
                '"' gt_exp-iqa '"' ','
*                '"' gt_exp-kunnr '"' ','
*                '"' gt_exp-name1 '"' ','
*                '"' gt_exp-fablt '"' ','
*                '"' gt_exp-wqty '"' ','
*                '"' gt_exp-dqty '"' ','
                '"' gt_exp-clabs '"'
                into xtab1.
    append xtab1.
    clear: xtab1, l_grdate.
  endloop.

endform.                    " format_file
*&---------------------------------------------------------------------*
*&      Form  download_serv
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form download_serv .

  if p_fname2 ne space.

     OPEN DATASET p_fname2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
     IF sy-subrc = 0.
        loop at xtab1.
            transfer xtab1 to p_fname2." length 195.
        endloop.
        CLOSE DATASET p_fname2.
        WRITE:/ 'Template is output to', p_fname2.
     ELSE.
        WRITE:/ 'Error File open error!'.
     ENDIF.


  endif.

endform.                    " download_serv
*&---------------------------------------------------------------------*
*&      Form  download_pc
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form download_pc .

data : l_fname type STRING.

if p_fname1 ne space.
  l_fname = p_fname1.

  CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    FILENAME                      = l_fname
    FILETYPE                      = 'ASC'
*   APPEND                        = ' '
*   WRITE_FIELD_SEPARATOR         = ' '
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   COL_SELECT                    = ' '
*   COL_SELECT_MASK               = ' '
*   DAT_MODE                      = ' '
*   CONFIRM_OVERWRITE             = ' '
*   NO_AUTH_CHECK                 = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   WRITE_BOM                     = ' '
* IMPORTING
*   FILELENGTH                    =
  TABLES
    DATA_TAB                      = xtab1[]
* EXCEPTIONS
*   FILE_WRITE_ERROR              = 1
*   NO_BATCH                      = 2
*   GUI_REFUSE_FILETRANSFER       = 3
*   INVALID_TYPE                  = 4
*   NO_AUTHORITY                  = 5
*   UNKNOWN_ERROR                 = 6
*   HEADER_NOT_ALLOWED            = 7
*   SEPARATOR_NOT_ALLOWED         = 8
*   FILESIZE_NOT_ALLOWED          = 9
*   HEADER_TOO_LONG               = 10
*   DP_ERROR_CREATE               = 11
*   DP_ERROR_SEND                 = 12
*   DP_ERROR_WRITE                = 13
*   UNKNOWN_DP_ERROR              = 14
*   ACCESS_DENIED                 = 15
*   DP_OUT_OF_MEMORY              = 16
*   DISK_FULL                     = 17
*   DP_TIMEOUT                    = 18
*   FILE_NOT_FOUND                = 19
*   DATAPROVIDER_EXCEPTION        = 20
*   CONTROL_FLUSH_ERROR           = 21
*   OTHERS                        = 22
          .
  IF SY-SUBRC = 0.
    WRITE:/ 'File is output to', l_fname.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

endif.

endform.                    " download_pc
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 -> PP 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.