Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

material ageing

$
0
0

hi,

i have created an alv z-program, which should be modified with ageing bucket specifications in selection screen.

when i give materialno ,plant,storagelocation,date,aging bucket values in input selection the output has to display

as

we wil calculate posting date through mkpf compare that date with keydate(input date) the diff between two dates is below

first bucket days in stock1 

 

in stock2 material quantity between first bucket days and second bucket days.

stock3 quantity between second and third.

stock4 between third and fourth.

stock5 quantity above fourth bucket days.

 

depending on material document capture posting date after that depending on movement type we have to add or substract quantity.

if u r using movement type check t156 table.

 

the output will match the values with material details quantity in tcode mb5b.

 

in stock1 quantity of material below the

matno   descrpton   plant   storloc  vendorstock 

 

 

Here is my coding, and would like to know coding for ageing bucket.

 

TABLES: STKO,

        MAST,

        STPO,

        MAKT,

        MARD,

        MARM,

        MSSL,

        CRHD,

        CRCO,

        AFVC,

        AFKO,

        AFRU,

        MBEW,

        MSEG,

        MKPF.

 

 

TYPES: BEGIN OF TY_STKO,

       STLNR TYPE STKO-STLNR,

       STLAL TYPE STKO-STLAL,

       STKOZ TYPE STKO-STKOZ,

       BMENG TYPE STKO-BMENG,

       BMEIN TYPE STKO-BMEIN,

       END OF TY_STKO.

DATA: I_STKO TYPE TABLE OF TY_STKO,

      WA_STKO TYPE TY_STKO.

 

TYPES: BEGIN OF TY_MAST,

       STLNR TYPE MAST-STLNR,

       STLAL TYPE MAST-STLAL,

       MATNR TYPE MAST-MATNR,

       WERKS TYPE MAST-WERKS,

       END OF TY_MAST.

DATA: I_MAST TYPE  TABLE OF TY_MAST,

      WA_MAST TYPE  TY_MAST.

 

TYPES: BEGIN OF TY_STPO,

       STLNR TYPE STPO-STLNR,

       STLKN TYPE STPO-STLKN,

       STPOZ TYPE STPO-STPOZ,

       IDNRK TYPE STPO-IDNRK,

       POSNR TYPE STPO-POSNR,

       MEINS TYPE STPO-MEINS,

       MENGE TYPE STPO-MENGE,

       END OF TY_STPO.

DATA: I_STPO TYPE TABLE OF TY_STPO,

      WA_STPO TYPE TY_STPO.

 

TYPES: BEGIN OF TY_MAKT,

       MATNR TYPE MAKT-MATNR,

       MAKTX TYPE MAKT-MAKTX,

       END OF TY_MAKT.

DATA: I_MAKT TYPE TABLE OF TY_MAKT,

      WA_MAKT TYPE TY_MAKT.

 

TYPES: BEGIN OF TY_MARD,

       MATNR TYPE MARD-MATNR,

       WERKS TYPE MARD-WERKS,

       LGORT TYPE MARD-LGORT,

       LABST TYPE MARD-LABST,

       END OF TY_MARD.

DATA: I_MARD TYPE TABLE OF TY_MARD,

      WA_MARD TYPE TY_MARD.

 

*DATA: BEGIN OF TY_MARM OCCURS 100.

*         INCLUDE STRUCTURE EMARM.

*  DATA:MATNR TYPE MARM-MATNR,

*        END OF TY_MARM.

 

TYPES: BEGIN OF TY_MSLB,

       MATNR TYPE MSLB-MATNR,

       LBLAB TYPE MSLB-LBLAB,

       END OF TY_MSLB.

DATA: I_MSLB TYPE TABLE OF TY_MSLB,

      WA_MSLB TYPE TY_MSLB.

 

TYPES: BEGIN OF TY_CRHD,

       OBJID TYPE CRHD-OBJID,

       END OF TY_CRHD.

DATA: I_CRHD TYPE TABLE OF TY_CRHD,

      WA_CRHD TYPE TY_CRHD.

 

*TYPES: BEGIN OF TY_CRCO,

*       OBJID TYPE CRCO-OBJID,

*

*       KOSTL TYPE CRCO-KOSTL,

*       END OF TY_CRCO.

*DATA: I_CRCO TYPE TABLE OF TY_CRCO,

*      WA_CRCO TYPE TY_CRCO.

 

TYPES: BEGIN OF TY_AFVC,

       ARBID TYPE AFVC-ARBID,

       AUFPL TYPE AFVC-AUFPL,

       END OF TY_AFVC.

DATA: I_AFVC TYPE TABLE OF TY_AFVC,

      WA_AFVC TYPE TY_AFVC.

 

TYPES: BEGIN OF TY_AFKO,

       AUFPL TYPE AFKO-AUFPL,

       AUFNR TYPE AFKO-AUFNR,

       END OF TY_AFKO.

DATA: I_AFKO TYPE TABLE OF TY_AFKO,

      WA_AFKO TYPE TY_AFKO.

 

*TYPES: BEGIN OF TY_AFRU,

*       AUFNR TYPE AFRU-AUFNR,

*

*       END OF TY_AFRU.

*DATA: I_AFRU TYPE TABLE OF TY_AFRU,

*      WA_AFRU TYPE TY_AFRU.

 

TYPES:BEGIN OF TY_MBEW,

      MATNR TYPE MBEW-MATNR,

      BWTAR TYPE MBEW-BWTAR,

      LBKUM TYPE MBEW-LBKUM,

      END OF TY_MBEW.

DATA: I_MBEW TYPE TABLE OF TY_MBEW,

      WA_MBEW TYPE TY_MBEW.

 

TYPES: BEGIN OF TY_MSEG,

       MATNR TYPE MSEG-MATNR,

       WERKS TYPE MSEG-WERKS,

       LGORT TYPE MSEG-LGORT,

       MBLNR TYPE MSEG-MBLNR,

       ZEILE TYPE MSEG-ZEILE,

       BWART TYPE MSEG-BWART,

       BWTAR TYPE MSEG-BWTAR,

       MENGE TYPE MSEG-MENGE,

       MEINS TYPE MSEG-MEINS,

       END OF TY_MSEG.

DATA: I_MSEG TYPE TABLE OF TY_MSEG,

      WA_MSEG TYPE TY_MSEG.

 

TYPES: BEGIN OF TY_MKPF,

       MBLNR TYPE MKPF-MBLNR,

       BUDAT TYPE MKPF-BUDAT,

       END OF TY_MKPF.

DATA: I_MKPF TYPE TABLE OF TY_MKPF,

      WA_MKPF TYPE TY_MKPF.

 

 

TYPES: BEGIN OF F_TAB,

       STLNR TYPE STKO-STLNR,

       STLAL TYPE STKO-STLAL,

       STKOZ TYPE STKO-STKOZ,

       BMENG TYPE STKO-BMENG,

       BMEIN TYPE STKO-BMEIN,

       MATNR TYPE MAST-MATNR,

       WERKS TYPE MAST-WERKS,

       STLKN TYPE STPO-STLKN,

       STPOZ TYPE STPO-STPOZ,

       IDNRK TYPE STPO-IDNRK,

       POSNR TYPE STPO-POSNR,

       MEINS TYPE STPO-MEINS,

       MENGE TYPE STPO-MENGE,

       MAKTX TYPE MAKT-MAKTX,

       LGORT TYPE MARD-LGORT,

       LABST TYPE MARD-LABST,

       LBLAB TYPE MSLB-LBLAB,

       OBJID TYPE CRHD-OBJID,

       KOSTL TYPE CRCO-KOSTL,

       ARBID TYPE AFVC-ARBID,

       AUFPL TYPE AFVC-AUFPL,

       AUFNR TYPE AFKO-AUFNR,

       BWTAR TYPE MBEW-BWTAR,

       LBKUM TYPE MBEW-LBKUM,

       MBLNR TYPE MSEG-MBLNR,

       ZEILE TYPE MSEG-ZEILE,

       BWART TYPE MSEG-BWART,

       BUDAT TYPE MKPF-BUDAT,

       END OF F_TAB.

DATA: I_TAB TYPE TABLE OF F_TAB,

      WA_TAB TYPE F_TAB.

 

*DATA: IT_MAST TYPE STANDARD TABLE OF MAST.

 

DATA: p_slab1(3) type c.

*&---------------------------------------------------------------------*

*&  Include           ZP00L

*&---------------------------------------------------------------------*

TYPE-POOLS: SLIS.

 

DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

      WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

 

*SELECTION SCREEN

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: MATERIAL FOR MAST-MATNR .

SELECT-OPTIONS: PLANT FOR MAST-WERKS OBLIGATORY.

SELECT-OPTIONS: LOCATION FOR MARD-LGORT OBLIGATORY.

*  parameters: p_date  like sy-datum .

parameters:   DATE like MKPF-BUDAT .

SELECTION-SCREEN END OF BLOCK B1.

 

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

SELECTION-SCREEN BEGIN OF LINE.

selection-screen comment 4(32) text-003 for field p_slab2.

PARAMETER:  p_slab2 like p_slab1 no-display,

            p_slab3 like p_slab1,

            p_slab4 like p_slab1,

            p_slab5 like p_slab1,

            p_slab6 like p_slab1.

SELECTION-SCREEN END OF Line.

SELECTION-SCREEN END OF BLOCK B2.

 

 

START-OF-SELECTION.

  PERFORM STAT.

 

END-OF-SELECTION.

  PERFORM CAT.

  PERFORM OUTPUT.

 

 

 

 

*&---------------------------------------------------------------------*

*&  Include           ZSQLS

*&---------------------------------------------------------------------*

FORM STAT.

  SELECT MATNR WERKS LGORT MBLNR ZEILE BWART BWTAR MENGE MEINS

                               FROM MSEG INTO TABLE I_MSEG

                               WHERE MATNR IN MATERIAL AND

                               WERKS IN PLANT AND

                               LGORT IN LOCATION.

  IF NOT I_MSEG IS INITIAL.

    SELECT MBLNR BUDAT FROM MKPF INTO TABLE I_MKPF

                             FOR ALL ENTRIES IN I_MSEG

                             WHERE MBLNR = I_MSEG-MBLNR.

  ENDIF.

 

  SELECT STLNR STLAL MATNR WERKS FROM MAST

                                 INTO TABLE I_MAST WHERE

                                 MATNR IN MATERIAL AND WERKS IN PLANT.

 

  IF SY-SUBRC = 0.

    SELECT MATNR WERKS LGORT LABST FROM MARD

                                 INTO TABLE I_MARD

                                 FOR ALL ENTRIES IN I_MAST

                                 WHERE LGORT IN LOCATION AND MATNR =

                                 I_MAST-MATNR.

    SELECT MATNR MAKTX FROM MAKT

                               INTO TABLE I_MAKT

                               FOR ALL ENTRIES IN I_MAST

                               WHERE MATNR = I_MAST-MATNR.

    SELECT MATNR LBLAB FROM MSLB

                                INTO TABLE I_MSLB

                                FOR ALL ENTRIES IN I_MAST

                                WHERE  MATNR = I_MAST-MATNR.

 

 

    SELECT STLNR STLAL STKOZ BMENG BMEIN FROM STKO

                               INTO TABLE I_STKO

                               FOR ALL ENTRIES IN I_MAST

                               WHERE STLNR = I_MAST-STLNR.

    IF NOT I_STKO IS INITIAL.

      SELECT STLNR STLKN STPOZ IDNRK POSNR MEINS MENGE FROM STPO

                                 INTO TABLE I_STPO

                                 FOR ALL ENTRIES IN I_STKO

                                 WHERE STLNR = I_STKO-STLNR.

    ENDIF.

  ENDIF.

  CLEAR WA_MSEG.

  SORT:I_MAKT BY MATNR.

  LOOP AT I_MSEG INTO WA_MSEG.

    WA_TAB-MATNR = WA_MSEG-MATNR.

    WA_TAB-WERKS = WA_MSEG-WERKS.

    WA_TAB-LGORT = WA_MSEG-LGORT.

    CLEAR:WA_MAKT.

    READ TABLE I_MAKT INTO WA_MAKT WITH KEY MATNR = WA_MSEG-MATNR BINARY SEARCH.

    IF SY-SUBRC = 0.

      WA_TAB-MAKTX = WA_MAKT-MAKTX.

    ENDIF.

    CLEAR:WA_MSLB.

    READ TABLE I_MSLB INTO WA_MSLB WITH KEY MATNR = WA_MSEG-MATNR BINARY SEARCH.

    IF SY-SUBRC = 0.

      WA_TAB-LBLAB = WA_MSLB-LBLAB.

    ENDIF.

    APPEND WA_TAB TO I_TAB.

 

  ENDLOOP.

ENDFORM.                    "STAT

 

 

*&---------------------------------------------------------------------*

*&      Form  CAT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

FORM CAT.

  WA_FIELDCAT-COL_POS = 1.

  WA_FIELDCAT-FIELDNAME = 'MATNR'.

  WA_FIELDCAT-KEY = 'X'.

  WA_FIELDCAT-JUST = 'C'.

  WA_FIELDCAT-SELTEXT_M = 'MATERIAL NUMBER'.

  WA_FIELDCAT-DDICTXT = 'M'.

  WA_FIELDCAT-OUTPUTLEN = 18.

 

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.

 

  WA_FIELDCAT-COL_POS = 2.

  WA_FIELDCAT-FIELDNAME = 'MAKTX'.

  WA_FIELDCAT-KEY = 'X'.

  WA_FIELDCAT-JUST = 'C'.

  WA_FIELDCAT-SELTEXT_M = 'DESCRIPTION'.

  WA_FIELDCAT-DDICTXT = 'M'.

  WA_FIELDCAT-OUTPUTLEN = 20.

 

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.

 

  WA_FIELDCAT-COL_POS = 3.

  WA_FIELDCAT-FIELDNAME = 'WERKS'.

  WA_FIELDCAT-KEY = 'X'.

  WA_FIELDCAT-JUST = 'C'.

  WA_FIELDCAT-SELTEXT_M = 'PLANT'.

  WA_FIELDCAT-DDICTXT = 'M'.

  WA_FIELDCAT-OUTPUTLEN = 6.

 

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.

 

  WA_FIELDCAT-COL_POS = 4.

  WA_FIELDCAT-FIELDNAME = 'LGORT'.

  WA_FIELDCAT-KEY = 'X'.

  WA_FIELDCAT-JUST = 'C'.

  WA_FIELDCAT-SELTEXT_M = 'STORAGE LOCATION'.

  WA_FIELDCAT-DDICTXT = 'M'.

  WA_FIELDCAT-OUTPUTLEN = 18.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.

 

  WA_FIELDCAT-COL_POS = 5.

  WA_FIELDCAT-FIELDNAME = 'LBLAB'.

  WA_FIELDCAT-KEY = 'X'.

  WA_FIELDCAT-JUST = 'C'.

  WA_FIELDCAT-SELTEXT_M = 'VENDOR STOCK'.

  WA_FIELDCAT-DDICTXT = 'M'.

  WA_FIELDCAT-OUTPUTLEN = 15.

 

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.

 

ENDFORM.                    "CAT

 

 

*&---------------------------------------------------------------------*

*&      Form  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

FORM OUTPUT.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

   EXPORTING

*       I_INTERFACE_CHECK                 = ' '

*       I_BYPASSING_BUFFER                = ' '

*       I_BUFFER_ACTIVE                   = ' '

     I_CALLBACK_PROGRAM                = SY-CPROG

*       I_CALLBACK_PF_STATUS_SET          = ' '

*       I_CALLBACK_USER_COMMAND           = ' '

*       I_CALLBACK_TOP_OF_PAGE            = ''

*       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '

*       I_CALLBACK_HTML_END_OF_LIST       = ' '

*       I_STRUCTURE_NAME                  =

*       I_BACKGROUND_ID                   = ' '

*       I_GRID_TITLE                      =

*       I_GRID_SETTINGS                   =

*       IS_LAYOUT                         =

     IT_FIELDCAT                       = IT_FIELDCAT

*       IT_EXCLUDING                      =

*       IT_SPECIAL_GROUPS                 =

*       IT_SORT                           =

*       IT_FILTER                         =

*       IS_SEL_HIDE                       =

*       I_DEFAULT                         = 'X'

*       I_SAVE                            = ' '

*       IS_VARIANT                        =

*       IT_EVENTS                         =

*       IT_EVENT_EXIT                     =

*       IS_PRINT                          =

*       IS_REPREP_ID                      =

*       I_SCREEN_START_COLUMN             = 0

*       I_SCREEN_START_LINE               = 0

*       I_SCREEN_END_COLUMN               = 0

*       I_SCREEN_END_LINE                 = 0

*       I_HTML_HEIGHT_TOP                 = 0

*       I_HTML_HEIGHT_END                 = 0

*       IT_ALV_GRAPHICS                   =

*       IT_HYPERLINK                      =

*       IT_ADD_FIELDCAT                   =

*       IT_EXCEPT_QINFO                   =

*       IR_SALV_FULLSCREEN_ADAPTER        =

*     IMPORTING

*       E_EXIT_CAUSED_BY_CALLER           =

*       ES_EXIT_CAUSED_BY_USER            =

    TABLES

      T_OUTTAB                          = I_TAB.

*     EXCEPTIONS

*       PROGRAM_ERROR                     = 1

*       OTHERS                            = 2

  .

*    IF SY-SUBRC <> 0.

** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*    ENDIF.

*

ENDFORM.                    "OUTPUT


Viewing all articles
Browse latest Browse all 8332

Trending Articles