Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

REPORT TAKING MORE CPU UTILIZATION

Hello Experts,

my following report is of sales order report it gives me an output in less than 250 seconds,

But taking 80 percentage CPU time so tell me how to overcome this problem ??

<b>&----


*& Report ZMSL_SALES_ORDER_REPORT

*&

&----


*&

*&

&----


REPORT ZMSL_SALES_ORDER_REPORT.

DEFINE: M_FIELDCAT.

ADD 1 TO LS_FIELDCAT-COL_POS.

LS_FIELDCAT-FIELDNAME = &1.

LS_FIELDCAT-SELTEXT_L = &2.

LS_FIELDCAT-OUTPUTLEN = &3.

LS_FIELDCAT-TABNAME = 'gt_final_data'.

APPEND LS_FIELDCAT TO FELD_CAT.

END-OF-DEFINITION.

*==================Start of Datebase tables Declaration=================

TABLES : VBAK, "Sales Document: Header Data

VBAP, "Sales Document: Item Data

MARA, "Matrial Master

VBEP, "Sales Document: Schedule Line Data

VBPA, "Sales Document: Partner

TVROT,

YMSLT_MAIL_ID.

*=================End of Datebase tables Declaration====================

*==================Start of Virable ALV declaration=================

**=============================

  • TYPE POOLS

*=============================

TYPE-POOLS: SLIS.

*=============================

*FIELD CATALOG DECLARATION

*=============================

CONSTANTS : CO_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME

VALUE 'TOP_OF_PAGE'.

DATA : G_TABNAME_HEADER TYPE SLIS_TABNAME,

G_TABNAME_ITEM TYPE SLIS_TABNAME.

DATA: FELD_CAT TYPE SLIS_T_FIELDCAT_ALV," WITH HEADER LINE ,

ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,

T_EVENTS TYPE SLIS_T_EVENT,

G_SAVE(1) TYPE C,

G_VARIANT LIKE DISVARIANT,

GX_VARIANT LIKE DISVARIANT,

EVENTS TYPE SLIS_T_EVENT,

G_EXIT(1) TYPE C,

LAYOUT TYPE SLIS_LAYOUT_ALV,

ALV_PRINT TYPE SLIS_PRINT_ALV,

ALV_DETAIL_FUNC(30),

  • EVENTS TYPE SLIS_T_EVENT,

T_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

RANGES : R_PARVW FOR VBPA-PARVW.

*=================End of Virable tables Declaration====================

*==================Start of Selection Screen Declaration================

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

SELECTION-SCREEN BEGIN OF BLOCK VAR WITH FRAME TITLE VARIANT.

PARAMETERS : P_VARI LIKE DISVARIANT-VARIANT.

SELECTION-SCREEN END OF BLOCK VAR.

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

SELECT-OPTIONS : S_VKORG FOR VBAK-VKORG OBLIGATORY, " Sales Org.

S_VKBUR FOR VBAK-VKBUR, " Sales Office

S_VKGRP FOR VBAK-VKGRP, " Sales Group

S_VTWEG FOR VBAK-VTWEG. " Distribution Channel

SELECTION-SCREEN :END OF BLOCK B2.

SELECTION-SCREEN :BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

SELECT-OPTIONS : S_KUNNR FOR VBAK-KUNNR, "Customer Number

S_VBELN FOR VBAK-VBELN, "Sales Order Number

S_ERDAT FOR VBAK-ERDAT, "OBLIGATORY, "Sales Order Date

S_AUGRU FOR VBAK-AUGRU, "Order Reason

S_BSTNK FOR VBAK-BSTNK, "PO Number

S_AUART FOR VBAK-AUART. "Sales order type

SELECTION-SCREEN :END OF BLOCK B3.

SELECTION-SCREEN :BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.

SELECT-OPTIONS : S_WERKS FOR VBAP-WERKS, "plant,

S_MATNR FOR VBAP-MATNR, " Matrial Code

S_PSTYV FOR VBAP-PSTYV, "Sales Order Item cat.

S_EDATU FOR VBEP-EDATU, "Conformatin Date

S_REQDAT FOR VBAP-ZZCUST_REQDAT. "Req.Del Date

SELECTION-SCREEN :END OF BLOCK B4.

SELECTION-SCREEN :BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-005.

SELECT-OPTIONS : S_ZE FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION , "Partner Function

S_ZS FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function

S_ZA FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function

S_ZR FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function

S_ZI FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION. "Partner Function

*FOR VBPA-KUNNR MATCHCODE OBJECT ZSMR ,

***

***SELECT-OPTIONS : S_ZE FOR VBPA-PARVW NO INTERVALS NO-EXTENSION , "Partner Function

      • S_ZS FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function

      • S_ZA FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function

      • S_ZR FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function

      • S_ZI FOR VBPA-PARVW NO INTERVALS NO-EXTENSION. "Partner Function

SELECTION-SCREEN :END OF BLOCK B5.

SELECTION-SCREEN : BEGIN OF BLOCK B6 WITH FRAME TITLE TEXT-006.

PARAMETER : P_SCREEN RADIOBUTTON GROUP RTYP DEFAULT 'X' USER-COMMAND

UCOMM ,

P_FILE RADIOBUTTON GROUP RTYP,

P_MAIL RADIOBUTTON GROUP RTYP.

SELECTION-SCREEN :END OF BLOCK B6.

SELECTION-SCREEN : BEGIN OF BLOCK B7 WITH FRAME TITLE TEXT-007.

PARAMETER : P_PEN RADIOBUTTON GROUP RE1 DEFAULT 'X' USER-COMMAND

UCOMM , " Pending Sales order

P_ALL RADIOBUTTON GROUP RE1, " ALL Sales order

P_BLOCK RADIOBUTTON GROUP RE1. " Blocked Sales order

  • P_DELE RADIOBUTTON GROUP RE1. " Delevered Sales order

SELECTION-SCREEN :END OF BLOCK B7.

SELECTION-SCREEN : END OF BLOCK B1.

*=================End of Selection Screen Declaration===================

*==================Start of Internal table Declaration==================

*----


Internal table for vbak

DATA : BEGIN OF GT_VBAK OCCURS 0 ,

VBELN LIKE VBAK-VBELN , " Sales Document Number

ERDAT LIKE VBAK-ERDAT , " Order Date

AUART LIKE VBAK-AUART, "Sales Document Type

VTWEG LIKE VBAK-VTWEG, "Distribution Channel

SPART LIKE VBAK-SPART, "Division

KNUMV LIKE VBAK-KNUMV , "Number of the document condition

BSTNK LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER

BSTDK LIKE VBAK-BSTDK, "Customer purchase order date

KUNNR LIKE VBAK-KUNNR, " Customer Code

ZOA_RECP_PLAN_DT LIKE VBAK-ZOA_RECP_PLAN_DT, "Order receipt at plant

END OF GT_VBAK.

*----


Internal table for VBAP

DATA : BEGIN OF GT_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN, " Sales Document Number

POSNR LIKE VBAP-POSNR, " Sales Doc. Line item number

MATNR LIKE VBAP-MATNR,

ABGRU LIKE VBAP-ABGRU, "Reason for rejection

MEINS LIKE VBAP-MEINS, "Base Unit of Measure

FAKSP LIKE VBAP-FAKSP,

NETWR LIKE VBAP-NETWR, " Net Value

KWMENG LIKE VBAP-KWMENG, " Order Quantity

WERKS LIKE VBAP-WERKS, "PLANT

LGORT LIKE VBAP-LGORT, "S.Loc

ROUTE LIKE VBAP-ROUTE, " Route

ZZWIDTH LIKE VBAP-ZZWIDTH, " widht

ZZKDMAT LIKE VBAP-ZZKDMAT, " customer Matrial

ZZBRAND LIKE VBAP-ZZBRAND, " bRAND

ZZSPLDIA LIKE VBAP-ZZSPLDIA, "Spool Diameter

ZZCUST_REQDAT LIKE VBAP-ZZCUST_REQDAT, " REquested Date

ZZCOATING LIKE VBAP-ZZCOATING,

ZZWEIGHT LIKE VBAP-ZZWEIGHT,

ZZWEIGHT_UMO LIKE VBAP-ZZWEIGHT_UMO,

END OF GT_VBAP.

*----


Internal table for VBEP

DATA : BEGIN OF GT_VBEP OCCURS 0,

VBELN LIKE VBEP-VBELN, " Sales Doc. Number

POSNR LIKE VBEP-POSNR, " Sales Doc. Item Number

ETENR LIKE VBEP-ETENR, "Delivery Schedule Line Number

EDATU LIKE VBEP-EDATU, "Schedule line date

END OF GT_VBEP.

*----


Internal table for VBPA

DATA : BEGIN OF GT_VBPA OCCURS 0,

VBELN LIKE VBAP-VBELN, "Sales Document Number

POSNR LIKE VBAP-POSNR, "Sales Document Item Number

PARVW LIKE VBPA-PARVW, "Partner Function

KUNNR LIKE VBPA-KUNNR, " Customer Number

END OF GT_VBPA.

*----


Internal table for VBKD

DATA : BEGIN OF GT_VBKD OCCURS 0,

VBELN LIKE VBKD-VBELN , " Sales Documet number

KDGRP LIKE VBKD-KDGRP, " Custoemr Group

INCO1 LIKE VBKD-INCO1, "Incoterms (Part 1)

INCO2 LIKE VBKD-INCO2, "Incoterms (Part 2)

ZTERM LIKE VBKD-ZTERM, " Payment Term

STCUR LIKE VBKD-STCUR, " Exchang Rate

END OF GT_VBKD.

*----


Internal table VBFA

DATA : BEGIN OF GT_VBFA OCCURS 0 ,

VBELV LIKE VBFA-VBELV, " Preceding sales and distribution document

POSNV LIKE VBFA-POSNV, "Preceding item of an SD document

VBELN LIKE VBFA-VBELN, "Subsequent sales and distribution document

POSNN LIKE VBFA-POSNN, "Subsequent item of an SD document

VBTYP_N LIKE VBFA-VBTYP_N, "Document category of subsequent document

RFMNG LIKE VBFA-RFMNG, "Referenced quantity in base unit of measure

END OF GT_VBFA.

*----


Internal table for KONV

DATA : BEGIN OF GT_KONV OCCURS 0,

KNUMV LIKE KONV-KNUMV, "Number of the document condition

KPOSN LIKE KONV-KPOSN, "Condition item number

KSCHL LIKE KONV-KSCHL , "Cond Type.

KBETR LIKE KONV-KBETR, " Rate per KG

WAERS LIKE KONV-WAERS, "currency

KWERT LIKE KONV-KWERT, "Condition value

END OF GT_KONV.

*----


Internal table for MSKA,

DATA : BEGIN OF GT_MSKA OCCURS 0,

MATNR LIKE MSKA-MATNR, "Matrial

WERKS LIKE MSKA-WERKS, "PLANT

LGORT LIKE MSKA-LGORT, "S. Loc

CHARG LIKE MSKA-CHARG,"Batch Number

SOBKZ LIKE MSKA-SOBKZ, "Special Stock Indicator

VBELN LIKE MSKA-VBELN , "Sales Doc Number

POSNR LIKE MSKA-POSNR, "Sales Doc Item Number

KALAB LIKE MSKA-KALAB, "Unrestricted-Use Stock

KAINS LIKE MSKA-KAINS, " Stock in Quality Inspection

END OF GT_MSKA.

*----


Internal table for MARD

DATA : BEGIN OF GT_MARD OCCURS 0 ,

MATNR LIKE MARD-MATNR, "Matrial

WERKS LIKE MARD-WERKS, "PLANT

LGORT LIKE MARD-LGORT, "S. Loc

LABST LIKE MARD-LABST, "Valuated Unrestricted-Use Stock

END OF GT_MARD.

*----


Internal table for KNA1

DATA : BEGIN OF GT_KNA1 OCCURS 0,

KUNNR LIKE KNA1-KUNNR , " Customer Number

NAME1 LIKE KNA1-NAME1, "Customer Name

NAME2 LIKE KNA1-NAME2, " Customer Name

ORT01 LIKE KNA1-ORT01, "City

END OF GT_KNA1.

DATA: BEGIN OF GT_KNA1_1 OCCURS 0,

KUNNR LIKE KNA1-KUNNR , " Customer Number

NAME1 LIKE KNA1-NAME1, "Customer Name

ORT01 LIKE KNA1-ORT01,

END OF GT_KNA1_1.

*----


Internal table for KNVV

DATA : BEGIN OF GT_KNVV OCCURS 0,

KUNNR LIKE KNVV-KUNNR , " Customer Number

KLABC LIKE KNVV-KLABC, " Custoemr Class

END OF GT_KNVV.

*----


Internal table for MAKT,

DATA : BEGIN OF GT_MAKT OCCURS 0,

MATNR LIKE MAKT-MATNR, "Matrial

SPRAS LIKE MAKT-SPRAS,

MAKTX LIKE MAKT-MAKTX, "Matrial DESC

MAKTG LIKE MAKT-MAKTG,

END OF GT_MAKT.

*----


Internal table for MVKE

DATA : BEGIN OF GT_MVKE OCCURS 0 ,

MATNR LIKE MVKE-MATNR, "Matrial

MVGR1 LIKE MVKE-MVGR1, " Matrial Group

END OF GT_MVKE.

*----


Internal table for TVM1T

DATA : BEGIN OF GT_TVM1T OCCURS 0 ,

SPRAS LIKE TVM1T-SPRAS,

MVGR1 LIKE TVM1T-MVGR1, " Matrial Group

BEZEI LIKE TVM1T-BEZEI, " Matrial Group DESC

END OF GT_TVM1T.

*----


Internal table for TSPAT

DATA : BEGIN OF GT_TSPAT OCCURS 0,

SPRAS LIKE TSPAT-SPRAS,

SPART LIKE VBAK-SPART, "Division

VTEXT LIKE TSPAT-VTEXT, "Division Desc

END OF GT_TSPAT.

*----


Internal table for TVTWT

DATA : BEGIN OF GT_TVTWT OCCURS 0 ,

SPRAS LIKE TVTWT-SPRAS,

VTWEG LIKE VBAK-VTWEG, " Distribution Channel

VTEXT LIKE TVTWT-VTEXT, "Distribution Channel Desc

END OF GT_TVTWT.

*----


Internal table for TVAKT

DATA : BEGIN OF GT_TVAKT OCCURS 0,

SPRAS LIKE TVAKT-SPRAS,

AUART LIKE VBAK-AUART, "Sales Document Type

BEZEI LIKE TVAKT-BEZEI, "sALES dOC TYPE Description

END OF GT_TVAKT .

*----


Internal table for T151t

DATA: BEGIN OF GT_VBUP OCCURS 0,

VBELN LIKE VBUP-VBELN,

POSNR LIKE VBUP-POSNR,

GBSTA LIKE VBUP-GBSTA,

END OF GT_VBUP.

DATA : BEGIN OF GT_T151T OCCURS 0,

SPRAS LIKE T151T-SPRAS,

KDGRP LIKE VBKD-KDGRP, " Custoemr Group

KTEXT LIKE T151T-KTEXT, " Custoemr Group Desc

END OF GT_T151T.

DATA : BEGIN OF GT_TVROT OCCURS 0,

SPRAS LIKE TVROT-SPRAS,

ROUTE LIKE TVROT-ROUTE, " Route code

BEZEI LIKE TVROT-BEZEI , " Route Desc

END OF GT_TVROT.

DATA : BEGIN OF GT_T052U OCCURS 0,

SPRAS LIKE T052U-SPRAS,

ZTERM LIKE T052U-ZTERM, " Payment terms

TEXT1 LIKE T052U-TEXT1, " text

END OF GT_T052U.

DATA: BEGIN OF GT_VBUK OCCURS 0,

VBELN LIKE VBUK-VBELN,

WBSTK LIKE VBUK-WBSTK,

END OF GT_VBUK.

*-------fINAL iNTERNAL TABLE FOR OUTPUT

DATA : BEGIN OF GT_FINAL_DATA OCCURS 0,

KUNNR LIKE VBAK-KUNNR, " cUSTOMER CODE

NAME(70) TYPE C, " cUSTOMER NAME

ORT01 LIKE KNA1-ORT01, "cITY

S_KUNNR LIKE VBAK-KUNNR, " cUSTOMER CODE

S_NAME(70) TYPE C, " cUSTOMER NAME

S_ORT01 LIKE KNA1-ORT01, "cITY

KLABC LIKE KNVV-KLABC, " Custoemr Class

VBELN(70) TYPE C, " LIKE VBAK-VBELN, "sALES oRDER nUMBER

POSNR LIKE VBAP-POSNR, "SALES ORDER LINE NUMBER

INCO1 LIKE VBKD-INCO1, "Incoterms (Part 1)

INCO2 LIKE VBKD-INCO2, "Incoterms (Part 2)

KALAB LIKE MSKA-KALAB, "Unrestricted-Use Stock

KAINS LIKE MSKA-KAINS, " Stock in Quality Inspection

LABST LIKE MARD-LABST, "Valuated Unrestricted-Use Stock

ERDAT LIKE VBAK-ERDAT , " Order Date

MATNR LIKE MAKT-MATNR, "Matrial

MAKTX LIKE MAKT-MAKTX, "Matrial DESC

MAKTG LIKE MAKT-MAKTG, "Matrial DESC

ZZKDMAT LIKE VBAP-ZZKDMAT, "Customter Mat. Number

ABGRU LIKE VBAP-ABGRU, " Reason for rejection

COLOR(20) TYPE C, "Color

COMPLEX(20) TYPE C, "Complex

WIDTH(10) TYPE C, "Width

KBETR LIKE KONV-KBETR, " Rate per KG

WAERS LIKE KONV-WAERS, "currency

STCUR LIKE VBKD-STCUR, " Exchang Rate

MEINS LIKE VBAP-MEINS, "Base Unit of Measure

KWMENG LIKE VBAP-KWMENG, " Order Quantity

RFMNG LIKE VBFA-RFMNG, "Referenced quantity in base unit of measure

BAL_QTY LIKE VBFA-RFMNG, " Balance QTY

EDATU LIKE VBEP-EDATU, "Schedule line date

DAYS(5) TYPE C, " Sch.Delay

BSTNK LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER

BSTDK LIKE VBAK-BSTDK, "Customer purchase order date

VTWEG LIKE VBAK-VTWEG, "Distribution Channel

SPART LIKE VBAK-SPART, "Division

DIST_NAME LIKE TVTWT-VTEXT, "Distribution Channels NAME

DIV_NAME LIKE TSPAT-VTEXT, "Sales Divisions NAME

ZA_KUNNR LIKE KNA1-KUNNR,

ZA_NAME LIKE KNA1-NAME1,

ZE_KUNNR LIKE KNA1-KUNNR,

ZE_NAME LIKE KNA1-NAME1,

ZI_KUNNR LIKE KNA1-KUNNR,

ZI_NAME LIKE KNA1-NAME1,

ZR_KUNNR LIKE KNA1-KUNNR,

ZR_NAME LIKE KNA1-NAME1,

ZS_KUNNR LIKE KNA1-KUNNR,

ZS_NAME LIKE KNA1-NAME1,

MVGR1(20) TYPE C , " Matrial Group

B_VALUE LIKE KONV-KWERT, "bASIC value

EX_VALUE LIKE KONV-KWERT, "eXCISE value

EC_VALUE LIKE KONV-KWERT, "ecess value

HE_VALUE LIKE KONV-KWERT, "hcess value

VAT_VALUE LIKE KONV-KWERT, "VAT value

CST_VALUE LIKE KONV-KWERT, "CST

F_VALUE LIKE KONV-KWERT, "fREIGJT

C_VALUE LIKE KONV-KWERT, "cOMISSION

KDGRP(70) TYPE C, " Custoemr Group

NETWR LIKE VBAP-NETWR, " Net Value

INR LIKE VBAP-NETWR, " inr Net Value

AUART LIKE VBAK-AUART, "Sales Document Type

BEZEI LIKE TVAKT-BEZEI, "SALES DOC TYPE DESC

ZOA_RECP_PLAN_DT LIKE VBAK-ZOA_RECP_PLAN_DT, "Order receipt at plant

ZZCUST_REQDAT LIKE VBAP-ZZCUST_REQDAT, " REquested Date

ROUTE LIKE VBAP-ROUTE, " Route

ROUTE_NAME LIKE TVROT-BEZEI , "Route name

ZZBRAND LIKE VBAP-ZZBRAND, " bRAND

ZZSPLDIA LIKE VBAP-ZZSPLDIA, "Spool Diameter

ZTERM LIKE VBKD-ZTERM, " Payment Term

Z_TERM_TEXT(50) TYPE C, "Payment Terms Text

Z001(50) TYPE C, "text

Z002(50) TYPE C, "text

Z003(50) TYPE C, "text

Z004(50) TYPE C, "text

ZI_001(50) TYPE C, "text

ZI_002(50) TYPE C, "text

ZZCOATING(20) TYPE C,

ZZWEIGHT LIKE VBAP-ZZWEIGHT,

ZZWEIGHT_UMO LIKE VBAP-ZZWEIGHT_UMO,

WBSTK LIKE VBUK-WBSTK,

T_NETWR LIKE VBAP-NETWR, " Net Value

FAKSP LIKE VBAP-FAKSP,

END OF GT_FINAL_DATA.

*****Mail Data Decleration.

DATA : BEGIN OF MAIL_TAB OCCURS 0 ,

ZE_NAME LIKE KNA1-NAME1,

ZS_NAME LIKE KNA1-NAME1,

NAME LIKE KNA1-NAME1,

ORT01 LIKE KNA1-ORT01, "cITY

S_NAME LIKE KNA1-NAME1,

S_ORT01 LIKE KNA1-ORT01, "cITY

KLABC LIKE KNVV-KLABC, " Custoemr Class

VBELN LIKE VBAK-VBELN, "sALES oRDER nUMBER

POSNR LIKE VBAP-POSNR, "SALES ORDER LINE NUMBER

ERDAT LIKE VBAK-ERDAT , " Order Date

MATNR LIKE MAKT-MATNR, "Matrial

MAKTX LIKE MAKT-MAKTX, "Matrial DESC

ZZKDMAT LIKE VBAP-ZZKDMAT, "Customter Mat. Number

COLOR(20) TYPE C, "Color

COMPLEX(20) TYPE C, "Complex

WIDTH(10) TYPE C, "Width

KBETR LIKE KONV-KBETR, " Rate per KG

WAERS LIKE KONV-WAERS, "currency

MEINS LIKE VBAP-MEINS, "Base Unit of Measure

KWMENG LIKE VBAP-KWMENG, " Order Quantity

BAL_QTY LIKE VBFA-RFMNG, " Balance QTY

EDATU LIKE VBEP-EDATU, "Schedule line date

DAYS(5) TYPE C, " Sch.Delay

BSTNK LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER

BSTDK LIKE VBAK-BSTDK, "Customer purchase order date

ZA_NAME LIKE KNA1-NAME1,

ZI_NAME LIKE KNA1-NAME1,

ZR_NAME LIKE KNA1-NAME1,

MVGR1(20) TYPE C , " Matrial Group

ZZCUST_REQDAT LIKE VBAP-ZZCUST_REQDAT, " REquested Date

ZZBRAND LIKE VBAP-ZZBRAND, " bRAND

END OF MAIL_TAB.

DATA : IT_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.

DATA : SM_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.

DATA : SP_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.

DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

W_CNT TYPE I,

W_SENT_ALL(1) TYPE C,

W_DOC_DATA LIKE SODOCCHGI1,

GD_ERROR TYPE SY-SUBRC,

GD_RECIEVER TYPE SY-SUBRC.

DATA STR_VAL TYPE STRING.

CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.

CONSTANTS:

CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,

CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.

DATA: GT_VBAK_KNA1 LIKE GT_VBAK OCCURS 0 WITH HEADER LINE,

GT_VBAP_VBPA LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,

GT_VBAP_MAKT LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,

GT_MVKE_TVM1T LIKE GT_MVKE OCCURS 0 WITH HEADER LINE,

GT_VBAP_MSKA LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,

GT_VBPA_KNA1 LIKE GT_VBPA OCCURS 0 WITH HEADER LINE,

GT_VBFA_VBUK LIKE GT_VBFA OCCURS 0 WITH HEADER LINE,

GT_VBAP_INOB LIKE GT_VBAP OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF GT_INOB OCCURS 0.

INCLUDE STRUCTURE INOB.

DATA : END OF GT_INOB.

DATA: BEGIN OF GT_YCAT_PARAMS OCCURS 0,

KEY01 TYPE YYKEY01_C10,

KEY02 TYPE YYKEY02_C16,

KEY03 TYPE YYKEY03_C20,

SRNO TYPE YYSRNO_N4,

VALUE TYPE YYVALUE_C25,

END OF GT_YCAT_PARAMS.

DATA: BEGIN OF GT_CABN OCCURS 0,

ATINN LIKE CABN-ATINN,

ATNAM LIKE CABN-ATNAM,

END OF GT_CABN.

DATA: BEGIN OF GT_AUSP OCCURS 0,

OBJEK LIKE AUSP-OBJEK,

ATINN LIKE AUSP-ATINN,

ATWRT LIKE AUSP-ATWRT,

END OF GT_AUSP.

DATA: BEGIN OF GT_CUOBJ OCCURS 0,

  • CUOBJ(18) TYPE C,

CUOBJ TYPE OBJNUM,

END OF GT_CUOBJ.

DATA: BEGIN OF GT_CAWN OCCURS 0,

ATINN LIKE CAWN-ATINN,

ATZHL LIKE CAWN-ATZHL,

ATWRT LIKE CAWN-ATWRT,

END OF GT_CAWN.

DATA: BEGIN OF GT_CAWNT OCCURS 0,

ATINN LIKE CAWNT-ATINN,

ATZHL LIKE CAWNT-ATZHL,

SPRAS LIKE CAWNT-SPRAS,

ATWTB LIKE CAWNT-ATWTB,

END OF GT_CAWNT.

----


  • START-OF-SELECTION *

----


INITIALIZATION.

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

VARIANT = 'Display Options'.

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

  • RB1 = 'X'.

  • REPNAME = SY-REPID.

PERFORM BUILD_EVENTTAB USING EVENTS[].

PERFORM BUILD_LAYOUT .

PERFORM INITIALIZE_VARIANT.

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

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

PERFORM F4_FOR_VARIANT.

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

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

END-OF-SELECTION.

PERFORM SELECT_DATA.

PERFORM PROCESS_DATA.

PERFORM FILTER_PATNER_DATA.

IF P_FILE = 'X'.

PERFORM OUT_PUT_FILE.

ELSEIF P_SCREEN = 'X'.

PERFORM FILED_CAT_LOG.

PERFORM CREATE_ALV_LAYOUT.

  • PERFORM fill_events.

PERFORM OUT_PUT_DATA.

ELSEIF P_MAIL = 'X'.

PERFORM MAIL_RPT.

ENDIF.

*=================Start of Internal table Declaration===================

*===========

&----


*& Form SELECT_DATA

&----


  • sELECTING DATA FROM dATA bASE

----


FORM SELECT_DATA .

REFRESH R_PARVW.

R_PARVW-SIGN = 'I'.

R_PARVW-OPTION = 'EQ'.

IF NOT S_ZE[] IS INITIAL.

R_PARVW-LOW = S_ZE-LOW.

APPEND R_PARVW.

ENDIF.

IF NOT S_ZS[] IS INITIAL.

R_PARVW-LOW = S_ZS-LOW.

APPEND R_PARVW.

ENDIF.

IF NOT S_ZA[] IS INITIAL.

R_PARVW-LOW = S_ZA-LOW.

APPEND R_PARVW.

ENDIF.

IF NOT S_ZR[] IS INITIAL.

R_PARVW-LOW = S_ZR-LOW.

APPEND R_PARVW.

ENDIF.

IF NOT S_ZI[] IS INITIAL.

R_PARVW-LOW = S_ZI-LOW.

APPEND R_PARVW.

ENDIF.

  • R_PARVW-LOW = 'SH'.

  • APPEND R_PARVW.

*----


sELECTING DATA FROM VBAK TABLE INTO INTERNAL TABLE GT_VBAK

SELECT VBELN ERDAT AUART

VTWEG SPART KNUMV

BSTNK BSTDK KUNNR

ZOA_RECP_PLAN_DT

INTO TABLE GT_VBAK

FROM VBAK

WHERE VBELN IN S_VBELN

AND ERDAT IN S_ERDAT

AND VBTYP = 'C'

AND AUART IN S_AUART

AND AUGRU IN S_AUGRU

AND VKORG IN S_VKORG

AND VTWEG IN S_VTWEG

AND VKGRP IN S_VKGRP

AND VKBUR IN S_VKBUR

AND BSTNK IN S_BSTNK

AND KUNNR IN S_KUNNR.

SORT GT_VBAK[] BY VBELN.

IF NOT GT_VBAK[] IS INITIAL.

*----


Selecting data from VBAP into Internal tabl gt_vbap

IF P_BLOCK = 'X' .

SELECT VBELN POSNR

MATNR ABGRU

MEINS FAKSP

NETWR KWMENG

WERKS LGORT

ROUTE ZZWIDTH

ZZKDMAT ZZBRAND

ZZSPLDIA ZZCUST_REQDAT

ZZCOATING ZZWEIGHT

ZZWEIGHT_UMO

INTO TABLE GT_VBAP

FROM VBAP

FOR ALL ENTRIES IN GT_VBAK

WHERE VBELN = GT_VBAK-VBELN

AND MATNR IN S_MATNR

AND ABGRU <> ''

AND WERKS IN S_WERKS

.

ELSEIF P_PEN = 'X'.

SELECT VBELN POSNR

MATNR ABGRU

MEINS FAKSP

NETWR KWMENG

WERKS LGORT

ROUTE ZZWIDTH

ZZKDMAT ZZBRAND

ZZSPLDIA ZZCUST_REQDAT

ZZCOATING ZZWEIGHT

ZZWEIGHT_UMO

INTO TABLE GT_VBAP

FROM VBAP

FOR ALL ENTRIES IN GT_VBAK

WHERE VBELN = GT_VBAK-VBELN

AND MATNR IN S_MATNR

AND FAKSP <> '10'

AND WERKS IN S_WERKS.

ELSE.

SELECT VBELN POSNR

MATNR ABGRU

MEINS FAKSP

NETWR KWMENG

WERKS LGORT

ROUTE ZZWIDTH

ZZKDMAT ZZBRAND

ZZSPLDIA ZZCUST_REQDAT

ZZCOATING ZZWEIGHT

ZZWEIGHT_UMO

INTO TABLE GT_VBAP

FROM VBAP

FOR ALL ENTRIES IN GT_VBAK

WHERE VBELN = GT_VBAK-VBELN

AND MATNR IN S_MATNR

AND WERKS IN S_WERKS.

ENDIF.

ENDIF.

  • IF P_PEN = 'X'.

  • SELECT VBELN POSNR GBSTA FROM VBUP INTO TABLE GT_VBUP

  • FOR ALL ENTRIES IN GT_VBAP

  • WHERE VBELN = GT_VBAP-VBELN AND POSNR = GT_VBAP-POSNR AND

  • GBSTA <> 'C'.

  • SORT GT_VBUP[] BY VBELN.

  • LOOP AT GT_VBAP.

  • READ TABLE GT_VBUP WITH KEY VBELN = GT_VBAP-VBELN

  • POSNR = GT_VBAP-POSNR.

  • IF SY-SUBRC <> 0.

  • DELETE GT_VBAP.

*

  • ENDIF.

  • CLEAR GT_VBUP.

  • ENDLOOP.

LOOP AT GT_VBAK.

READ TABLE GT_VBAP WITH KEY VBELN = GT_VBAK-VBELN.

IF SY-SUBRC <> 0.

DELETE GT_VBAK.

ENDIF.

CLEAR GT_VBAP.

ENDLOOP.

  • ENDIF.

IF NOT GT_VBAP[] IS INITIAL.

GT_VBAP_INOB[] = GT_VBAP[].

SORT GT_VBAP_INOB[] BY MATNR.

DELETE ADJACENT DUPLICATES FROM GT_VBAP_INOB COMPARING MATNR.

SELECT * FROM INOB INTO TABLE GT_INOB

WHERE KLART = '023'

AND OBTAB = 'MARA'.

IF SY-SUBRC = 0.

SELECT KEY01 KEY02 KEY03 SRNO VALUE

INTO TABLE Gt_YCAT_PARAMS

FROM YCAT_PARAMS

WHERE KEY01 = 'CHAR_NAME'

AND KEY02 = 'ATNAM'

AND ( KEY03 = 'COLOR' OR KEY03 = 'COMPLEX' )

AND SRNO = '0001'.

SELECT ATINN ATNAM INTO TABLE GT_CABN FROM CABN

WHERE ( ATNAM = 'COLOUR' OR ATNAM = 'COMPLEX' ).

LOOP AT GT_INOB.

GT_CUOBJ-CUOBJ = GT_INOB-CUOBJ.

APPEND GT_CUOBJ.

ENDLOOP.

SELECT OBJEK ATINN ATWRT

INTO TABLE GT_AUSP FROM AUSP

FOR ALL ENTRIES IN GT_CUOBJ

WHERE OBJEK = GT_CUOBJ-CUOBJ.

  • AND ATINN = L_ATINN.

SELECT ATINN ATZHL ATWRT INTO TABLE GT_CAWN

FROM CAWN FOR ALL ENTRIES IN GT_AUSP

WHERE ATWRT = GT_AUSP-ATWRT.

SELECT ATINN ATZHL SPRAS ATWTB INTO TABLE GT_CAWNT

FROM CAWNT FOR ALL ENTRIES IN GT_CAWN

WHERE ATINN = GT_CAWN-ATINN

AND ATZHL = GT_CAWN-ATZHL

AND SPRAS = 'EN'.

ENDIF.

*----


Selecting data from VBeP into Internal tabl gt_vbep

SORT GT_VBAP[] BY VBELN POSNR.

SELECT VBELN POSNR

ETENR EDATU

INTO TABLE GT_VBEP

FROM VBEP

FOR ALL ENTRIES IN GT_VBAP

WHERE VBELN = GT_VBAP-VBELN

AND POSNR = GT_VBAP-POSNR

AND EDATU IN S_EDATU

AND BMENG <> 0.

SELECT SPRAS ROUTE BEZEI

INTO TABLE GT_TVROT

FROM TVROT

WHERE SPRAS = 'EN'.

ENDIF.

IF NOT GT_VBAP[] IS INITIAL.

GT_VBAP_VBPA[] = GT_VBAP[].

SORT GT_VBAP_VBPA[] BY VBELN.

DELETE ADJACENT DUPLICATES FROM GT_VBAP_VBPA COMPARING VBELN.

*----


Selecting data from VBPA into Internal tabl GT_VBPA

IF NOT R_PARVW[] IS INITIAL.

SELECT VBELN POSNR

PARVW KUNNR

INTO TABLE GT_VBPA

FROM VBPA

FOR ALL ENTRIES IN GT_VBAP_VBPA

WHERE VBELN = GT_VBAP_VBPA-VBELN

AND ( PARVW IN R_PARVW

OR PARVW = 'WE' ).

ELSE.

SELECT VBELN POSNR

PARVW KUNNR

INTO TABLE GT_VBPA

FROM VBPA

FOR ALL ENTRIES IN GT_VBAP_VBPA

WHERE VBELN = GT_VBAP_VBPA-VBELN

AND ( PARVW = 'ZE'

OR PARVW = 'ZS'

OR PARVW = 'ZA'

OR PARVW = 'ZR'

OR PARVW = 'ZI' OR PARVW = 'WE' ).

ENDIF.

ENDIF.

SORT GT_VBPA[].

GT_VBPA_KNA1[] = GT_VBPA[].

SORT GT_VBPA_KNA1[] BY KUNNR.

DELETE ADJACENT DUPLICATES FROM GT_VBPA_KNA1 COMPARING KUNNR.

IF NOT GT_VBPA_KNA1[] IS INITIAL.

SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE

GT_KNA1_1 FOR ALL ENTRIES IN GT_VBPA_KNA1

WHERE KUNNR = GT_VBPA_KNA1-KUNNR.

ENDIF.

*----


Selecting data from VBKD into Internal tabl GT_VBKD

IF NOT GT_VBAK[] IS INITIAL.

SELECT VBELN KDGRP

INCO1 INCO2

ZTERM STCUR

INTO TABLE GT_VBKD

FROM VBKD

FOR ALL ENTRIES IN GT_VBAK

WHERE VBELN = GT_VBAK-VBELN

AND PRSDT <> ''.

*----


Selecting data from VBFA into Internal table gt_vbfa

IF P_PEN = 'X'.

SELECT VBFAVBELV VBFAPOSNV

VBFAVBELN VBFAPOSNN

VBFAVBTYP_N VBFARFMNG

INTO TABLE GT_VBFA

FROM VBFA INNER JOIN

VBAK ON VBFAVBELV = VBAKVBELN

WHERE

( VBFA~VBTYP_N = 'J' OR

VBFA~VBTYP_N = 'R').

LOOP AT GT_VBFA.

READ TABLE GT_VBAK WITH KEY VBELN = Gt_VBFA-VBELV.

IF SY-SUBRC <> 0.

DELETE GT_VBFA.

ENDIF.

CLEAR GT_VBFA.

ENDLOOP.

  • SELECT VBELV POSNV

  • VBELN POSNN

  • VBTYP_N RFMNG

  • INTO TABLE GT_VBFA

  • FROM VBFA

  • FOR ALL ENTRIES IN GT_VBAK

  • WHERE VBELV = GT_VBAK-VBELN

  • AND ( VBTYP_N = 'J' OR

  • VBTYP_N = 'R').

ELSE.

SELECT VBELV POSNV

VBELN POSNN

VBTYP_N RFMNG

INTO TABLE GT_VBFA

FROM VBFA

FOR ALL ENTRIES IN GT_VBAK

WHERE VBELV = GT_VBAK-VBELN

AND VBTYP_N = 'J'.

ENDIF.

SORT GT_VBFA[].

IF GT_VBFA[] IS NOT INITIAL.

GT_VBFA_VBUK[] = GT_VBFA[].

SORT GT_VBFA_VBUK[] BY VBELN.

DELETE ADJACENT DUPLICATES FROM GT_VBFA_VBUK COMPARING VBELN.

SELECT VBELN WBSTK FROM VBUK INTO TABLE GT_VBUK

FOR ALL ENTRIES IN GT_VBFA_VBUK

WHERE VBELN = GT_VBFA_VBUK-VBELN.

ENDIF.

  • -----------Selection data from KONv into Internal table gt_konv

SORT GT_VBAK[] BY KNUMV.

SELECT KNUMV KPOSN KSCHL

KBETR WAERS KWERT

INTO TABLE GT_KONV

FROM KONV

FOR ALL ENTRIES IN GT_VBAK

WHERE KNUMV = GT_VBAK-KNUMV

AND ( KSCHL = 'ZBAP'

OR KSCHL = 'JEXP'

OR KSCHL = 'JEDC'

OR KSCHL = 'JEDH'

OR KSCHL = 'ZJIP'

OR KSCHL = 'ZCOM'

OR KSCHL = 'JIVC'

OR KSCHL = 'JFRE' ).

ENDIF.

IF NOT GT_VBAP[] IS INITIAL.

*----


sELECING dATA FROM MSKA INTO INTERNAL TABLE GT_MSKA

GT_VBAP_MSKA[] = GT_VBAP[].

SORT GT_VBAP_MSKA[] BY MATNR WERKS VBELN POSNR.

DELETE ADJACENT DUPLICATES FROM GT_VBAP_MSKA COMPARING MATNR WERKS VBELN POSNR.

SELECT MATNR WERKS

LGORT CHARG

SOBKZ VBELN

POSNR

KALAB KAINS

INTO TABLE GT_MSKA

FROM MSKA

FOR ALL ENTRIES IN GT_VBAP_MSKA

WHERE MATNR = GT_VBAP_MSKA-MATNR

AND WERKS = GT_VBAP_MSKA-WERKS

  • AND LGORT = GT_VBAP-LGORT

AND VBELN = GT_VBAP_MSKA-VBELN

AND POSNR = GT_VBAP_MSKA-POSNR.

SORT GT_MSKA[].

DATA :BEGIN OF TMP_MATNR OCCURS 0,

MATNR LIKE MARA-MATNR,

END OF TMP_MATNR.

LOOP AT GT_VBAP.

TMP_MATNR-MATNR = GT_VBAP-MATNR.

TMP_MATNR-MATNR+0(1) ='S'.

APPEND TMP_MATNR.

ENDLOOP.

SORT TMP_MATNR[].

DELETE ADJACENT DUPLICATES FROM TMP_MATNR COMPARING MATNR.

SELECT MATNR

WERKS

LGORT

LABST

FROM MARD

INTO TABLE GT_MARD

FOR ALL ENTRIES IN TMP_MATNR

WHERE MATNR = TMP_MATNR-MATNR."'SDX25000B040GC01'."GT_VBAP-MATNR.

ENDIF.

SORT GT_MARD[].

IF NOT GT_VBAK[] IS INITIAL.

GT_VBAK_KNA1[] = GT_VBAK[].

SORT GT_VBAK_KNA1[] BY KUNNR.

DELETE ADJACENT DUPLICATES FROM GT_VBAK_KNA1 COMPARING KUNNR.

SELECT KUNNR

NAME1

NAME2

ORT01

FROM KNA1

INTO TABLE GT_KNA1

FOR ALL ENTRIES IN GT_VBAK_KNA1

WHERE KUNNR = GT_VBAK_KNA1-KUNNR.

SELECT KUNNR KLABC

FROM KNVV

INTO TABLE GT_KNVV

FOR ALL ENTRIES IN GT_VBAK_KNA1

WHERE KUNNR = GT_VBAK_KNA1-KUNNR.

ENDIF.

IF NOT GT_VBAP[] IS INITIAL.

GT_VBAP_MAKT[] = GT_VBAP[].

SORT GT_VBAP_MAKT[] BY MATNR.

DELETE ADJACENT DUPLICATES FROM GT_VBAP_MAKT COMPARING MATNR.

SELECT MATNR

SPRAS

MAKTX

FROM MAKT

INTO TABLE GT_MAKT

FOR ALL ENTRIES IN GT_VBAP_MAKT

WHERE MATNR = GT_VBAP_MAKT-MATNR AND

SPRAS = 'EN'.

SELECT MATNR

MVGR1

FROM MVKE

INTO TABLE GT_MVKE

FOR ALL ENTRIES IN GT_VBAP_MAKT

WHERE MATNR = GT_VBAP_MAKT-MATNR

AND MVGR1 <> ''.

ENDIF.

IF NOT GT_MVKE[] IS INITIAL.

GT_MVKE_TVM1T[] = GT_MVKE[].

SORT GT_MVKE_TVM1T[] BY MVGR1.

DELETE ADJACENT DUPLICATES FROM GT_MVKE_TVM1T COMPARING MVGR1.

SELECT SPRAS MVGR1 BEZEI

FROM TVM1T

INTO TABLE GT_TVM1T

FOR ALL ENTRIES IN GT_MVKE_TVM1T

WHERE SPRAS = 'EN' AND

MVGR1 = GT_MVKE_TVM1T-MVGR1.

ENDIF.

IF NOT GT_VBAK[] IS INITIAL.

SELECT SPRAS

SPART

VTEXT

FROM TSPAT

INTO TABLE GT_TSPAT

WHERE SPRAS = 'EN'.

SELECT SPRAS

VTWEG

VTEXT

FROM TVTWT

INTO TABLE GT_TVTWT

WHERE SPRAS = 'EN'.

SELECT SPRAS AUART BEZEI

FROM TVAKT

INTO TABLE GT_TVAKT

WHERE

SPRAS = 'EN'.

ENDIF.

IF NOT GT_VBKD[] IS INITIAL.

SELECT SPRAS KDGRP

KTEXT

FROM T151T

INTO TABLE GT_T151T

  • FOR ALL ENTRIES IN GT_VBKD

WHERE SPRAS = 'EN' .

  • AND

  • KDGRP = GT_VBKD-KDGRP.

ENDIF.

IF NOT GT_VBKD[] IS INITIAL.

SELECT SPRAS ZTERM TEXT1

FROM T052U

INTO TABLE GT_T052U

  • FOR ALL ENTRIES IN GT_VBKD

WHERE SPRAS = 'EN'.

  • AND ZTERM = GT_VBKD-ZTERM.

  • .

ENDIF.

ENDFORM. " SELECT_DATA

&----


*& Form PROCESS_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PROCESS_DATA .

DATA : T_FLAG(2) TYPE C,

J_AMT LIKE VBFA-RFMNG,

M_AMT LIKE VBFA-RFMNG,

R_AMT LIKE VBFA-RFMNG,

N_AMT LIKE VBFA-RFMNG,

JR_AMT LIKE VBFA-RFMNG,

MN_AMT LIKE VBFA-RFMNG,

TMP_WBSTK LIKE VBUK-WBSTK,

SFG_MATNR LIKE MARD-MATNR.

LOOP AT GT_VBAP.

CLEAR : GT_FINAL_DATA,

J_AMT ,

M_AMT ,

R_AMT,

N_AMT ,

JR_AMT ,

SFG_MATNR,

MN_AMT .

READ TABLE GT_VBAK WITH KEY VBELN = GT_VBAP-VBELN.

IF SY-SUBRC = 0.

GT_FINAL_DATA-KUNNR = GT_VBAK-KUNNR.

GT_FINAL_DATA-VBELN = GT_VBAK-VBELN.

GT_FINAL_DATA-POSNR = GT_VBAP-POSNR.

GT_FINAL_DATA-ABGRU = GT_VBAP-ABGRU.

ENDIF.

READ TABLE GT_KNA1 WITH KEY KUNNR = GT_VBAK-KUNNR.

IF SY-SUBRC = 0.

GT_FINAL_DATA-NAME = GT_KNA1-NAME1.

GT_FINAL_DATA-ORT01 = GT_KNA1-ORT01.

ENDIF.

READ TABLE GT_KNVV WITH KEY KUNNR = GT_VBAK-KUNNR.

IF SY-SUBRC = 0.

GT_FINAL_DATA-KLABC = GT_KNVV-KLABC.

ENDIF.

IF SY-SUBRC = 0.

READ TABLE GT_VBKD WITH KEY VBELN = GT_VBAK-VBELN.

GT_FINAL_DATA-INCO1 = GT_VBKD-INCO1. "Incoterms (Part 1)

GT_FINAL_DATA-INCO2 = GT_VBKD-INCO2. "Incoterms (Part 2)

GT_FINAL_DATA-ZTERM = GT_VBKD-ZTERM. " Payment Term

ENDIF.

LOOP AT GT_MSKA WHERE MATNR = GT_VBAP-MATNR

AND WERKS = GT_VBAP-WERKS

AND LGORT = GT_VBAP-LGORT

AND VBELN = GT_VBAP-VBELN

AND POSNR = GT_VBAP-POSNR.

GT_FINAL_DATA-KALAB = GT_FINAL_DATA-KALAB + GT_MSKA-KALAB. "Unrestricted-Use Stock

GT_FINAL_DATA-KAINS = GT_FINAL_DATA-KAINS + GT_MSKA-KAINS. " Stock in Quality Inspection

ENDLOOP.

SFG_MATNR = GT_VBAP-MATNR.

SFG_MATNR+0(1) ='S'.

READ TABLE GT_MARD WITH KEY MATNR = SFG_MATNR

WERKS = GT_VBAP-WERKS

LGORT = 'SF01'.

  • loop at gt_mard where MATNR = SFG_MATNR

  • and WERKS = GT_VBAP-WERKS.

IF SY-SUBRC = 0.

GT_FINAL_DATA-LABST = GT_FINAL_DATA-LABST + GT_MARD-LABST . "Valuated Unrestricted-Use Stock

ENDIF.

  • endloop.

GT_FINAL_DATA-MATNR = GT_VBAP-MATNR. "Matrial

GT_FINAL_DATA-ZZKDMAT = GT_VBAP-ZZKDMAT. " Customer Mat. Number

READ TABLE GT_MAKT WITH KEY MATNR = GT_VBAP-MATNR.

IF SY-SUBRC = 0.

GT_FINAL_DATA-MAKTX = GT_MAKT-MAKTX.

GT_FINAL_DATA-MAKTG = GT_MAKT-MAKTG.

ENDIF.

GT_FINAL_DATA-ERDAT = GT_VBAK-ERDAT.

*

  • READ TABLE GT_KONV WITH KEY KNUMV = GT_VBAK-KNUMV

  • KSCHL = 'ZBAP'.

  • loop at gt_konv where KNUMV = GT_VBAK-KNUMV

  • and KSCHL = 'ZBAP'

  • and

  • IF SY-SUBRC = 0.

  • GT_FINAL_DATA-KBETR = GT_KONV-KBETR. " Rate per KG

  • GT_FINAL_DATA-WAERS = GT_KONV-WAERS. "currency

  • ENDIF.

GT_FINAL_DATA-STCUR = GT_VBKD-STCUR. " Exchang Rate

GT_FINAL_DATA-MEINS = GT_VBAP-MEINS. "Base Unit of Measure

GT_FINAL_DATA-KWMENG = GT_VBAP-KWMENG. " Order Quantity

GT_FINAL_DATA-WIDTH = GT_VBAP-ZZWIDTH. " width

GT_FINAL_DATA-ROUTE = GT_VBAP-ROUTE. " route

IF GT_VBAP-ZZCOATING = 'IN'.

GT_FINAL_DATA-ZZCOATING = 'Inside Coating'.

ELSEIF GT_VBAP-ZZCOATING = 'OUT'.

GT_FINAL_DATA-ZZCOATING = 'Outside Coating'.

ENDIF.

GT_FINAL_DATA-ZZWEIGHT = GT_VBAP-ZZWEIGHT.

GT_FINAL_DATA-ZZWEIGHT_UMO = GT_VBAP-ZZWEIGHT_UMO.

LOOP AT GT_VBFA WHERE VBELV = GT_VBAK-VBELN

AND POSNV = GT_VBAP-POSNR.

      • IF P_DELE = 'X'.

***

      • IF GT_VBFA-VBTYP_N = 'J'.

      • SELECT SINGLE WBSTK

      • INTO GT_FINAL_DATA-WBSTK

      • FROM VBUK

      • WHERE VBELN = GT_VBFA-VBELN.

      • IF SY-SUBRC = 0.

      • J_AMT = J_AMT + GT_VBFA-RFMNG.

      • ENDIF.

      • ENDIF.

      • GT_FINAL_DATA-RFMNG = J_AMT .

IF P_PEN = 'X'.

IF GT_VBFA-VBTYP_N = 'J'.

GT_FINAL_DATA-RFMNG = GT_FINAL_DATA-RFMNG + GT_VBFA-RFMNG.

READ TABLE GT_VBUK WITH KEY VBELN = GT_VBFA-VBELN.

IF SY-SUBRC = 0.

GT_FINAL_DATA-WBSTK = GT_VBUK-WBSTK.

  • SELECT SINGLE WBSTK

  • INTO GT_FINAL_DATA-WBSTK

  • FROM VBUK

  • WHERE VBELN = GT_VBFA-VBELN.

ELSE.

T_FLAG = 'XX'.

ENDIF.

ENDIF.

ELSE.

GT_FINAL_DATA-RFMNG = GT_FINAL_DATA-RFMNG + GT_VBFA-RFMNG.

ENDIF.

ENDLOOP.

GT_FINAL_DATA-BAL_QTY = GT_FINAL_DATA-KWMENG - GT_FINAL_DATA-RFMNG . " Balance QTY

READ TABLE GT_VBEP WITH KEY VBELN = GT_VBAP-VBELN

POSNR = GT_VBAP-POSNR.

IF SY-SUBRC = 0.

GT_FINAL_DATA-EDATU = GT_VBEP-EDATU. "Schedule line date

GT_FINAL_DATA-DAYS = SY-DATUM - GT_VBEP-EDATU.

ENDIF.

GT_FINAL_DATA-BSTNK = GT_VBAK-BSTNK. " cUSTOMER pURCHASE ORDER NUMBER

GT_FINAL_DATA-BSTDK = GT_VBAK-BSTDK. "Customer purchase order date

GT_FINAL_DATA-VTWEG = GT_VBAK-VTWEG. "Distribution Channel

READ TABLE GT_TVTWT WITH KEY VTWEG = GT_VBAK-VTWEG.

IF SY-SUBRC = 0.

GT_FINAL_DATA-DIST_NAME = GT_TVTWT-VTEXT.

ENDIF.

GT_FINAL_DATA-SPART = GT_VBAK-SPART. "Division

READ TABLE GT_TSPAT WITH KEY SPART = GT_VBAK-SPART.

IF SY-SUBRC = 0.

GT_FINAL_DATA-DIV_NAME = GT_TSPAT-VTEXT. "Sales Divisions NAME

ENDIF.

CLEAR T_FLAG.

PERFORM NAME_DATA USING GT_VBAP-VBELN changing T_FLAG.

  • LOOP AT GT_VBPA WHERE VBELN = GT_VBAP-VBELN.

  • CASE GT_VBPA-PARVW .

  • WHEN 'ZA'.

  • GT_FINAL_DATA-ZA_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-ZA_NAME = GT_KNA1_1-NAME1.

*

  • T_FLAG ='XX'.

*

  • WHEN 'ZE'.

  • GT_FINAL_DATA-ZE_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-ZE_NAME = GT_KNA1_1-NAME1.

  • T_FLAG ='XX'.

  • WHEN 'ZI'.

  • GT_FINAL_DATA-ZI_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-ZI_NAME = GT_KNA1_1-NAME1.

  • T_FLAG ='XX'.

  • WHEN 'ZR'.

  • GT_FINAL_DATA-ZR_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-ZR_NAME = GT_KNA1_1-NAME1.

  • T_FLAG ='XX'.

  • WHEN 'ZS'.

  • GT_FINAL_DATA-ZS_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-ZS_NAME = GT_KNA1_1-NAME1.

  • T_FLAG ='XX'.

  • WHEN 'WE'.

  • GT_FINAL_DATA-S_KUNNR = GT_VBPA-KUNNR.

  • READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

  • GT_FINAL_DATA-S_NAME = GT_KNA1_1-NAME1.

  • GT_FINAL_DATA-S_ORT01 = GT_KNA1_1-ORT01.

  • T_FLAG ='XX'.

  • ENDCASE.

  • ENDLOOP.

READ TABLE GT_MVKE WITH KEY MATNR = GT_VBAP-MATNR.

READ TABLE GT_TVM1T WITH KEY MVGR1 = GT_MVKE-MVGR1.

IF SY-SUBRC = 0.

GT_FINAL_DATA-MVGR1 = GT_TVM1T-BEZEI.

ENDIF.

PERFORM VALUE_DATA USING GT_VBAK-KNUMV GT_VBAP-POSNR.

  • LOOP AT GT_KONV WHERE KNUMV = GT_VBAK-KNUMV

  • AND KPOSN = GT_VBAP-POSNR.

  • CASE GT_KONV-KSCHL.

  • WHEN 'ZBAP'.

  • GT_FINAL_DATA-B_VALUE = GT_KONV-KWERT.

  • GT_FINAL_DATA-KBETR = GT_KONV-KBETR. " Rate per KG

  • GT_FINAL_DATA-WAERS = GT_KONV-WAERS. "currency

  • WHEN 'JEXP'.

  • GT_FINAL_DATA-EX_VALUE = GT_KONV-KWERT.

  • WHEN 'JEDC'.

  • GT_FINAL_DATA-EC_VALUE = GT_KONV-KWERT.

  • WHEN 'JEDH'.

  • GT_FINAL_DATA-HE_VALUE = GT_KONV-KWERT.

  • WHEN 'JIVP'.

  • GT_FINAL_DATA-VAT_VALUE = GT_KONV-KWERT.

  • WHEN 'JIVC'.

  • GT_FINAL_DATA-CST_VALUE = GT_KONV-KWERT.

  • WHEN 'ZCOM'.

  • GT_FINAL_DATA-C_VALUE = GT_KONV-KWERT.

  • WHEN 'JFRE'.

  • GT_FINAL_DATA-F_VALUE = GT_KONV-KWERT.

  • ENDCASE.

  • ENDLOOP .

GT_FINAL_DATA-T_NETWR = ( GT_VBAP-NETWR + GT_FINAL_DATA-EX_VALUE + GT_FINAL_DATA-EC_VALUE +

GT_FINAL_DATA-HE_VALUE + GT_FINAL_DATA-VAT_VALUE + GT_FINAL_DATA-CST_VALUE +

GT_FINAL_DATA-C_VALUE + GT_FINAL_DATA-F_VALUE ).

READ TABLE GT_T151T WITH KEY KDGRP = GT_VBKD-KDGRP.

IF SY-SUBRC = 0.

GT_FINAL_DATA-KDGRP = GT_T151T-KTEXT. " Custoemr Group

ENDIF.

GT_FINAL_DATA-NETWR = GT_VBAP-NETWR. " Net Value

GT_FINAL_DATA-INR = GT_VBAP-NETWR. " INR Net Value

GT_FINAL_DATA-AUART = GT_VBAK-AUART. "Sales Document Type

READ TABLE GT_TVAKT WITH KEY AUART = GT_VBAK-AUART.

IF SY-SUBRC = 0.

GT_FINAL_DATA-BEZEI = GT_TVAKT-BEZEI.

ENDIF.

GT_FINAL_DATA-ZOA_RECP_PLAN_DT = GT_VBAK-ZOA_RECP_PLAN_DT. "Order receipt at plant

GT_FINAL_DATA-ZZCUST_REQDAT = GT_VBAP-ZZCUST_REQDAT . " Cust. Req. Date

READ TABLE GT_TVROT WITH KEY ROUTE = GT_VBAP-ROUTE.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ROUTE_NAME = GT_TVROT-BEZEI .

ENDIF.

PERFORM COLOR_COMPLEX_WIDTH.

GT_FINAL_DATA-ZZBRAND = GT_VBAP-ZZBRAND. " bRAND

GT_FINAL_DATA-ZZSPLDIA = GT_VBAP-ZZSPLDIA. "Spool Diameter

GT_FINAL_DATA-FAKSP = GT_VBAP-FAKSP.

READ TABLE GT_T052U WITH KEY ZTERM = GT_VBKD-ZTERM.

IF SY-SUBRC = 0.

GT_FINAL_DATA-Z_TERM_TEXT = GT_T052U-TEXT1.

ENDIF.

PERFORM TEXT_DATA.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = GT_FINAL_DATA-VBELN

IMPORTING

OUTPUT = GT_FINAL_DATA-VBELN.

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

  • EXPORTING

  • INPUT = GT_FINAL_DATA-VBELN

  • IMPORTING

  • OUTPUT = GT_FINAL_DATA-VBELN.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = GT_FINAL_DATA-KUNNR

IMPORTING

OUTPUT = GT_FINAL_DATA-KUNNR.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = GT_FINAL_DATA-S_KUNNR

IMPORTING

OUTPUT = GT_FINAL_DATA-S_KUNNR.

IF T_FLAG = 'XX'.

APPEND GT_FINAL_DATA.

ENDIF.

ENDLOOP.

IF P_PEN = 'X'.

DELETE GT_FINAL_DATA WHERE BAL_QTY <= 0.

DELETE GT_FINAL_DATA WHERE FAKSP = 10.

  • *WBSTK = 'C'.

ENDIF.

  • IF P_DELE = 'X'.

  • DELETE GT_FINAL_DATA WHERE RFMNG = 0 .

  • ENDIF.

SORT GT_FINAL_DATA BY VBELN POSNR.

ENDFORM. " PROCESS_DATA

&----


*& Form FILED_CAT_LOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILED_CAT_LOG .

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR : FELD_CAT.

M_FIELDCAT 'KUNNR' 'Cust.Cd' '15'.

M_FIELDCAT 'NAME' 'Cust.name' '70'.

M_FIELDCAT 'ORT01' 'Destination' '35'.

M_FIELDCAT 'S_KUNNR' 'Ship To Party Code' '15'.

M_FIELDCAT 'S_NAME' 'Ship To Party Name' '70'.

M_FIELDCAT 'S_ORT01' 'Party Distination' '35'.

M_FIELDCAT 'KLABC' 'Customer Class' '15'.

M_FIELDCAT 'VBELN' 'Sales Doc' '15'.

M_FIELDCAT 'POSNR' 'Sales Doc Item' '15'.

M_FIELDCAT 'INCO1' 'Incoterms1' '15'.

M_FIELDCAT 'INCO2' 'Incoterms2' '15'.

M_FIELDCAT 'KALAB' 'FG-OK Stock' '15'.

M_FIELDCAT 'KAINS' 'FG-HOLD Stock' '15'.

M_FIELDCAT 'LABST' 'SFG Stock' '15'.

M_FIELDCAT 'ERDAT' 'Order.Dat' '15'.

M_FIELDCAT 'MATNR' 'Mat.Code' '50'.

M_FIELDCAT 'MAKTX' 'Matrial Desc.' '15'.

M_FIELDCAT 'COLOR' 'Color' '15'.

M_FIELDCAT 'COMPLEX' 'Complex' '50'.

M_FIELDCAT 'WIDTH' 'Width.' '6'.

M_FIELDCAT 'KBETR' 'Rate/kg' '15'.

M_FIELDCAT 'WAERS' 'Currency' '15'.

M_FIELDCAT 'STCUR' 'Exchange rate' '15'.

M_FIELDCAT 'MEINS' 'UoM' '15'.

M_FIELDCAT 'KWMENG' 'Order Qty.' '15'.

M_FIELDCAT 'RFMNG' 'Dispatched Qty' '15'.

M_FIELDCAT 'BAL_QTY' 'Balance Qty(KGs)' '15'.

M_FIELDCAT 'EDATU' 'Ori.Sch.Date' '15'.

M_FIELDCAT 'DAYS' 'Sch.Delay' '15'.

M_FIELDCAT 'BSTNK' 'Cust.P.O.No' '30'.

M_FIELDCAT 'BSTDK' 'Cust.P.O.Date' '15'.

M_FIELDCAT 'VTWEG' 'Distr.Channel' '15'.

M_FIELDCAT 'DIST_NAME' 'Distr.Channel Name' '15'.

M_FIELDCAT 'SPART' 'Division' '15'.

M_FIELDCAT 'DIV_NAME' 'Division Name' '15'.

M_FIELDCAT 'ZA_KUNNR' 'Area Manager' '50'.

M_FIELDCAT 'ZA_NAME' 'Area Manager Name' '50'.

M_FIELDCAT 'ZE_KUNNR' 'Sales Manager' '50'.

M_FIELDCAT 'ZE_NAME' 'Sales Manager Name' '50'.

M_FIELDCAT 'ZI_KUNNR' 'ISP Manager' '50'.

M_FIELDCAT 'ZI_NAME' 'ISP Manager Name' '50'.

M_FIELDCAT 'ZR_KUNNR' 'Regional Manager' '15'.

M_FIELDCAT 'ZR_NAME' 'Regional Manager' '50'.

M_FIELDCAT 'ZS_KUNNR' 'Support Manager' '15'.

M_FIELDCAT 'ZS_NAME' 'Support Manager Name' '50'.

M_FIELDCAT 'MVGR1' 'Matrial Grp.' '5'.

M_FIELDCAT 'B_VALUE' 'Basic Value' '15'.

M_FIELDCAT 'EX_VALUE' 'Excise' '15'.

M_FIELDCAT 'EC_VALUE' 'E Cess Value' '15'.

M_FIELDCAT 'HE_VALUE' 'H Cess Value' '15'.

M_FIELDCAT 'VAT_VALUE' 'VAT Value' '15'.

M_FIELDCAT 'CST_VALUE' 'CST Value' '15'.

M_FIELDCAT 'F_VALUE' 'Feright' '15'.

M_FIELDCAT 'C_VALUE' 'Commission' '15'.

M_FIELDCAT 'KDGRP' 'Customer Grp' '15'.

M_FIELDCAT 'T_NETWR' 'Ord. Amount' '15'.

M_FIELDCAT 'INR' 'Ord.Amount INR' '15'.

M_FIELDCAT 'AUART' 'Sales Document Type' '15'.

M_FIELDCAT 'BEZEI' 'Desc. Sales Document Type' '30'.

M_FIELDCAT 'ZOA_RECP_PLAN_DT' 'Ord. Receipt at Plant' '20'.

M_FIELDCAT 'ZZCUST_REQDAT' 'Cust. Req. Date' '20'.

M_FIELDCAT 'ROUTE' 'Route' '20'.

M_FIELDCAT 'ROUTE_NAME' 'Route Name' '20'.

M_FIELDCAT 'ZZKDMAT' 'Customer Mat. Number' '50'.

M_FIELDCAT 'ZZBRAND' 'Brand' '50'.

M_FIELDCAT 'ZZSPLDIA' 'Spool Diameter' '50'.

M_FIELDCAT 'ZTERM' 'Payment Terms' '50'.

M_FIELDCAT 'Z_TERM_TEXT' 'Payment Terms Desc.' '50'.

M_FIELDCAT 'Z001' 'Header Texts 1' '50'.

M_FIELDCAT 'Z002' 'Header Texts 2' '50'.

M_FIELDCAT 'Z003' 'Header Texts 3' '50'.

M_FIELDCAT 'Z004' 'Header Texts 4' '50'.

M_FIELDCAT 'ZI_001' 'Item Texts 1' '50'.

M_FIELDCAT 'ZI_002' 'Item Texts 2' '50'.

M_FIELDCAT 'ZZCOATING' 'Coating Side' '50'.

M_FIELDCAT 'ZZWEIGHT' 'Spool Weight' '50'.

M_FIELDCAT 'ZZWEIGHT_UMO' 'UMO' '50'.

  • LIKE VBKD-ZTERM, " Payment Term

  • LIKE VBAP-ZZBRAND, " bRAND

  • LIKE VBAP-ZZSPLDIA, "Spool Diameter

ENDFORM. " FILED_CAT_LOG

&----


*& Form OUT_PUT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM OUT_PUT_DATA .

DATA TITLE(70) TYPE C.

IF P_ALL = 'X'.

TITLE = 'ALL SALES ORDER REPORT'.

ELSEIF P_PEN = 'X'.

TITLE = 'PENDING SALES ORDER REPORT'.

  • ELSEIF P_DELE = 'X'.

  • TITLE = 'DELIVERED SALES ORDER REPORT'.

ELSEIF P_BLOCK = 'X'.

TITLE = 'BLOCKED SALES ORDER REPORT'.

ELSE.

TITLE = 'SALES ORDER REPORT'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • 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 = TITLE

  • I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT"ALV_LAYOUT

IT_FIELDCAT = FELD_CAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = G_SAVE

IS_VARIANT = G_VARIANT

  • IT_EVENTS = EVENTS[]

IS_PRINT = ALV_PRINT

  • 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 = GT_FINAL_DATA

  • 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.

  • CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

  • I_CALLBACK_PROGRAM = sy-REPID

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • IS_LAYOUT = LAYOUT

  • IT_FIELDCAT = FELD_CAT[]

  • I_SAVE = G_SAVE

  • IS_VARIANT = G_VARIANT

    • IT_EVENTS = EVENTS[]

  • IS_PRINT = ALV_PRINT

  • TABLES

  • T_OUTTAB = GT_FINAL_DATA

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2.

ENDFORM. " OUT_PUT_DATA

&----


*& Form create_alv_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CREATE_ALV_LAYOUT .

ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM. " create_alv_layout

----


*& Form fill_events

&----


  • ALV Event fill

----


FORM FILL_EVENTS USING LT_EV TYPE SLIS_T_EVENT.

*-- Declaration

DATA: WA_EVENT TYPE SLIS_ALV_EVENT.

*-- Read in all possible events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = LT_EV.

*-- top-of-page

READ TABLE LT_EV WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO WA_EVENT.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = CO_FORMNAME_TOP_OF_PAGE.

MODIFY LT_EV FROM WA_EVENT INDEX SY-TABIX.

ENDIF.

ENDFORM. " fill_events

&----


*& Form OUT_PUT_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM OUT_PUT_FILE .

CALL FUNCTION 'DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

  • FILENAME = ' '

FILETYPE = 'DAT'

  • ITEM = ' '

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • FILEMASK_MASK = ' '

  • FILEMASK_TEXT = ' '

  • FILETYPE_NO_CHANGE = ' '

  • FILEMASK_ALL = ' '

  • FILETYPE_NO_SHOW = ' '

  • SILENT = 'M'

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • ACT_FILENAME =

  • ACT_FILETYPE =

  • FILESIZE =

  • CANCEL =

TABLES

DATA_TAB = GT_FINAL_DATA

  • FIELDNAMES =

EXCEPTIONS

INVALID_FILESIZE = 1

INVALID_TABLE_WIDTH = 2

INVALID_TYPE = 3

NO_BATCH = 4

UNKNOWN_ERROR = 5

GUI_REFUSE_FILETRANSFER = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

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

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

ELSE.

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

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

ENDIF.

ENDFORM. " OUT_PUT_FILE

&----


*& Form color_complex_width

&----


  • text

----


FORM COLOR_COMPLEX_WIDTH.

DATA : L_VALUE(15) TYPE C,

V_VALUE(15) TYPE C,

L_ATINN(30) TYPE C,

T_COMPLEX(30) TYPE C,

T_COLOR(30) TYPE C,

T_MATNR TYPE OBJNUM,

T_CUOBJ(50) TYPE C.

DATA: L_ATZHL LIKE CAWN-ATZHL,

L_ATWRT LIKE CAWN-ATWRT,

L_SPRAS LIKE CAWNT-SPRAS.

T_MATNR = GT_VBAP-MATNR.

READ TABLE Gt_INOB WITH KEY "KLART = '023'

"OBTAB = 'MARA'

OBJEK = T_MATNR.

CLEAR T_MATNR.

  • SELECT SINGLE *

  • INTO GT_INOB

  • FROM INOB

  • WHERE KLART = '023'

  • AND OBTAB = 'MARA'

  • AND OBJEK = GT_VBAP-MATNR.

--


To Read value from--

IF SY-SUBRC EQ 0.

READ TABLE GT_YCAT_PARAMS WITH KEY KEY01 = 'CHAR_NAME'

KEY02 = 'ATNAM'

KEY03 = 'COMPLEX'

SRNO = '0001'.

  • SELECT SINGLE VALUE INTO L_VALUE

  • FROM YCAT_PARAMS

  • WHERE KEY01 = 'CHAR_NAME'

  • AND KEY02 = 'ATNAM'

  • AND KEY03 = 'COMPLEX'

  • AND SRNO = '0001'.

V_VALUE = GT_YCAT_PARAMS-VALUE.

IF NOT V_VALUE IS INITIAL.

READ TABLE GT_CABN WITH KEY ATNAM = V_VALUE.

  • SELECT SINGLE ATINN INTO L_ATINN FROM CABN

  • WHERE ATNAM = V_VALUE.

ENDIF.

T_CUOBJ = GT_INOB-CUOBJ.

L_ATINN = Gt_CABN-ATINN.

READ TABLE GT_AUSP WITH KEY OBJEK = T_CUOBJ

ATINN = L_ATINN."GT_CABN-ATINN.

*CLEAR T_CUOBJ.

  • SELECT SINGLE ATWRT

  • INTO T_COMPLEX

  • FROM AUSP

  • WHERE OBJEK = GT_INOB-CUOBJ

  • AND ATINN = L_ATINN. "'0000000098'

T_COMPLEX = GT_AUSP-ATWRT.

CLEAR V_VALUE.

CLEAR L_ATINN.

READ TABLE GT_YCAT_PARAMS WITH KEY KEY01 = 'CHAR_NAME'

KEY02 = 'ATNAM'

KEY03 = 'COLOR'

SRNO = '0001'.

  • SELECT SINGLE VALUE INTO L_VALUE

  • FROM YCAT_PARAMS

  • WHERE KEY01 = 'CHAR_NAME'

  • AND KEY02 = 'ATNAM'

  • AND KEY03 = 'COLOR'

  • AND SRNO = '0001'.

V_VALUE = GT_YCAT_PARAMS-VALUE.

IF NOT V_VALUE IS INITIAL.

CLEAR GT_CABN.

READ TABLE GT_CABN WITH KEY ATNAM = V_VALUE.

  • SELECT SINGLE ATINN INTO L_ATINN FROM CABN

  • WHERE ATNAM = V_VALUE.

L_ATINN = GT_CABN-ATINN.

ENDIF.

ENDIF.

CLEAR: T_COLOR, L_ATWRT, L_ATZHL, L_SPRAS.

READ TABLE GT_AUSP WITH KEY OBJEK = T_CUOBJ

ATINN = L_ATINN."GT_CABN-ATINN.

L_ATWRT = GT_AUSP-ATWRT.

  • SELECT SINGLE ATWRT

  • INTO L_ATWRT

  • FROM AUSP

  • WHERE OBJEK = T_CUOBJ"GT_INOB-CUOBJ

  • AND ATINN = L_ATINN.

READ TABLE GT_CAWN WITH KEY ATINN = L_ATINN

ATWRT = L_ATWRT.

*L_ATINN = GT_CAWN-ATINN.

L_ATZHL = GT_CAWN-ATZHL.

  • SELECT SINGLE ATINN ATZHL

  • INTO (L_ATINN, L_ATZHL)

  • FROM CAWN

  • WHERE ATINN = L_ATINN

  • AND ATWRT = L_ATWRT.

  • L_SPRAS = 'EN'.

READ TABLE GT_CAWNT WITH KEY ATINN = L_ATINN

ATZHL = L_ATZHL.

  • SELECT SINGLE ATWTB

  • INTO T_COLOR

  • FROM CAWNT

  • WHERE ATINN = L_ATINN

  • AND ATZHL = L_ATZHL

  • AND SPRAS = L_SPRAS. "'0000000099'.

T_COLOR = GT_CAWNT-ATWTB.

GT_FINAL_DATA-COMPLEX = T_COMPLEX .

GT_FINAL_DATA-COLOR = T_COLOR .

ENDFORM. "color_complex_width

&----


*& Form text_data

&----


  • updading TExt fields of sales order

----


FORM TEXT_DATA .

DATA : BEGIN OF GT_TEXT OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA : END OF GT_TEXT.

DATA: TEST_VBELN(70) TYPE C.

CONCATENATE GT_VBAP-VBELN GT_VBAP-POSNR INTO TEST_VBELN.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'Z001'

LANGUAGE = SY-LANGU

NAME = GT_FINAL_DATA-VBELN

OBJECT = 'VBBK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

GT_FINAL_DATA-Z001 = ''.

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-Z001 = GT_TEXT-TDLINE .

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'Z002'

LANGUAGE = SY-LANGU

NAME = GT_FINAL_DATA-VBELN

OBJECT = 'VBBK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

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

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

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-Z002 = GT_TEXT-TDLINE.

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'Z003'

LANGUAGE = SY-LANGU

NAME = GT_FINAL_DATA-VBELN

OBJECT = 'VBBK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

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

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

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-Z003 = GT_TEXT-TDLINE.

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'Z004'

LANGUAGE = SY-LANGU

NAME = GT_FINAL_DATA-VBELN

OBJECT = 'VBBK'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

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

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

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-Z004 = GT_TEXT-TDLINE.

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = '0001'

LANGUAGE = SY-LANGU

NAME = TEST_VBELN

OBJECT = 'VBBP'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

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

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

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-ZI_001 = GT_TEXT-TDLINE.

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = '0002'

LANGUAGE = SY-LANGU

NAME = TEST_VBELN

OBJECT = 'VBBP'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = GT_TEXT

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.

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

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

ELSE.

CLEAR GT_TEXT.

READ TABLE GT_TEXT.

GT_FINAL_DATA-ZI_002 = GT_TEXT-TDLINE.

ENDIF.

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • ID = 'Z002'

  • LANGUAGE = 'EN'

  • NAME = '0002000040'

  • OBJECT = 'VBBK'

  • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • TABLES

  • LINES = GT_TEXT

    • 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.

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

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

*ENDIF.

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • ID = 'Z003'

  • LANGUAGE = 'EN'

  • NAME = GT_VBAK-VBELN

  • OBJECT = 'VBBK'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • TABLES

  • LINES = GT_TEXT

    • 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.

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

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

*ENDIF.

*

*

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • ID = 'Z004'

  • LANGUAGE = 'EN'

  • NAME = GT_VBAK-VBELN

  • OBJECT = 'VBBK'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • TABLES

  • LINES = GT_TEXT

    • 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.

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

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

*ENDIF.

*

ENDFORM. " text_dataf

&----


*& Form BUILD_EVENTTAB

&----


  • text

----


  • -->P_EVENTS text

----


FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_EVENTS.

READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO P_EVENTS.

ENDIF.

ENDFORM. " BUILD_EVENTTAB

*&----


*& form initialize_variant

*&----


  • text

*----


  • --> p1 text

  • <-- p2 text

*----


FORM INITIALIZE_VARIANT.

G_SAVE = 'A'.

CLEAR G_VARIANT.

G_VARIANT-REPORT = SY-REPID.

GX_VARIANT = G_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.

LAYOUT-GET_SELINFOS = 'X'.

LAYOUT-GROUP_CHANGE_EDIT = 'X'.

ALV_PRINT-NO_PRINT_SELINFOS = 'X'.

ALV_PRINT-NO_COVERPAGE = 'X'.

ALV_PRINT-NO_PRINT_LISTINFOS = 'X'.

ALV_DETAIL_FUNC = 'REUSE_ALV_LIST_DISPLAY'.

ENDFORM. " INITIALIZE_VARIANT

&----


*& Form F4_FOR_VARIANT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F4_FOR_VARIANT.

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

  • CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

  • EXPORTING

  • is_variant = g_variant

  • i_save = g_save

  • 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.

G_VARIANT-REPORT = SY-REPID.

GX_VARIANT-REPORT = SY-REPID.

G_SAVE = 'A'.

G_VARIANT = SY-REPID.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT

I_SAVE = 'A'

I_TABNAME_HEADER = G_TABNAME_HEADER

I_TABNAME_ITEM = G_TABNAME_ITEM

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

&----


  • text

----


*----


  • --> 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 INITIALIZE_VARIANT.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

&----


*& Form BUILD_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_LAYOUT.

  • layout-f2code = f2code.

  • layout-zebra = 'X'.

LAYOUT-DETAIL_POPUP = 'X'.

LAYOUT-NO_VLINE = '1'.

LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form filter_patner_Data

&----


  • text

----


FORM FILTER_PATNER_DATA .

IF S_ZE IS NOT INITIAL.

DELETE GT_FINAL_DATA WHERE ZE_KUNNR NOT IN S_ZE.

ENDIF.

IF S_ZS IS NOT INITIAL.

DELETE GT_FINAL_DATA WHERE ZS_KUNNR NOT IN S_ZS.

ENDIF.

IF S_ZA IS NOT INITIAL.

DELETE GT_FINAL_DATA WHERE ZA_KUNNR NOT IN S_ZA.

ENDIF.

IF S_ZR IS NOT INITIAL.

DELETE GT_FINAL_DATA WHERE ZR_KUNNR NOT IN S_ZR.

ENDIF.

IF S_ZI IS NOT INITIAL.

DELETE GT_FINAL_DATA WHERE ZI_KUNNR NOT IN S_ZI.

ENDIF.

ENDFORM. " filter_patner_Data

&----


*& Form MAIL_RPT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM MAIL_RPT .

PERFORM POPULATE_EMAIL_MESSAGE_BODY.

PERFORM BUILD_XLS_DATA_TABLE USING G_VARIANT-VARIANT.

ENDFORM. " MAIL_RPT

&----


*& Form BUILD_XLS_DATA_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_XLS_DATA_TABLE USING P_VARIANT.

SELECT * FROM YMSLT_MAIL_ID INTO CORRESPONDING FIELDS OF TABLE IT_MAIL_ID.

  • WHERE ZVARIANT = P_VARIANT.

CHECK NOT IT_MAIL_ID[] IS INITIAL.

LOOP AT IT_MAIL_ID.

CLEAR :T_RECEIVERS,IT_ATTACH,MAIL_TAB.

REFRESH :T_RECEIVERS,IT_ATTACH,MAIL_TAB.

PERFORM MAIL_TO_SM USING IT_MAIL_ID-ZEMAIL_ID

IT_MAIL_ID-ZSMCODE.

CLEAR :T_RECEIVERS,IT_ATTACH,MAIL_TAB.

REFRESH :T_RECEIVERS,IT_ATTACH,MAIL_TAB.

PERFORM MAIL_TO_SP USING IT_MAIL_ID-ZEMAIL_ID

IT_MAIL_ID-ZSPCODE.

ENDLOOP.

ENDFORM. " BUILD_XLS_DATA_TABLE

&----


*& Form POPULATE_EMAIL_MESSAGE_BODY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM POPULATE_EMAIL_MESSAGE_BODY .

REFRESH IT_MESSAGE.

IT_MESSAGE = 'Please find attached a list of Pending Sales Order Rpt '.

APPEND IT_MESSAGE.

ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY

&----


*& Form SEND_FILE_AS_EMAIL_ATTACHMENT

&----


  • text

----


  • -->P_IT_MESSAGE text

  • -->P_IT_ATTACH text

  • -->P_5619 text

  • -->P_5620 text

  • -->P_5621 text

  • -->P_5622 text

  • -->P_5623 text

  • -->P_5624 text

  • <--P_GD_ERROR text

  • <--P_GD_RECIEVER text

----


FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE

PIT_ATTACH

USING P_MTITLE

P_FORMAT

P_FILENAME

P_ATTDESCRIPTION

P_SENDER_ADDRESS

P_SENDER_ADDRES_TYPE

CHANGING P_ERROR

P_RECIEVER.

DATA: LD_ERROR TYPE SY-SUBRC,

LD_RECIEVER TYPE SY-SUBRC,

LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,

LD_EMAIL LIKE SOMLRECI1-RECEIVER,

LD_FORMAT TYPE SO_OBJ_TP ,

LD_ATTDESCRIPTION TYPE SO_OBJ_DES ,

LD_ATTFILENAME TYPE SO_OBJ_NAM ,

LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,

LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,

LD_RECEIVER LIKE SY-SUBRC.

  • LD_EMAIL = P_EMAIL.

LD_MTITLE = P_MTITLE.

LD_FORMAT = P_FORMAT.

LD_ATTDESCRIPTION = P_ATTDESCRIPTION.

LD_ATTFILENAME = P_FILENAME.

LD_SENDER_ADDRESS = P_SENDER_ADDRESS.

LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.

  • Fill the document data.

W_DOC_DATA-DOC_SIZE = 1.

  • Populate the subject/generic message attributes

W_DOC_DATA-OBJ_LANGU = SY-LANGU.

W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

W_DOC_DATA-OBJ_DESCR = LD_MTITLE .

W_DOC_DATA-SENSITIVTY = 'F'.

  • Fill the document data and get size of attachment

CLEAR W_DOC_DATA.

READ TABLE IT_ATTACH INDEX W_CNT.

W_DOC_DATA-DOC_SIZE =

( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).

W_DOC_DATA-OBJ_LANGU = SY-LANGU.

W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

W_DOC_DATA-OBJ_DESCR = LD_MTITLE.

W_DOC_DATA-SENSITIVTY = 'F'.

CLEAR T_ATTACHMENT.

REFRESH T_ATTACHMENT.

T_ATTACHMENT[] = PIT_ATTACH[].

  • Describe the body of the message

CLEAR T_PACKING_LIST.

REFRESH T_PACKING_LIST.

T_PACKING_LIST-TRANSF_BIN = SPACE.

T_PACKING_LIST-HEAD_START = 1.

T_PACKING_LIST-HEAD_NUM = 0.

T_PACKING_LIST-BODY_START = 1.

DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

T_PACKING_LIST-DOC_TYPE = 'RAW'.

APPEND T_PACKING_LIST.

  • Create attachment notification

T_PACKING_LIST-TRANSF_BIN = 'X'.

T_PACKING_LIST-HEAD_START = 1.

T_PACKING_LIST-HEAD_NUM = 1.

T_PACKING_LIST-BODY_START = 1.

DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.

T_PACKING_LIST-DOC_TYPE = LD_FORMAT.

T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.

T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.

T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.

APPEND T_PACKING_LIST.

  • Add the recipients email address

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = W_DOC_DATA

PUT_IN_OUTBOX = 'X'

SENDER_ADDRESS = LD_SENDER_ADDRESS

SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE

COMMIT_WORK = 'X'

IMPORTING

SENT_TO_ALL = W_SENT_ALL

TABLES

PACKING_LIST = T_PACKING_LIST

CONTENTS_BIN = T_ATTACHMENT

CONTENTS_TXT = IT_MESSAGE

RECEIVERS = T_RECEIVERS

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

DOCUMENT_TYPE_NOT_EXIST = 3

OPERATION_NO_AUTHORIZATION = 4

PARAMETER_ERROR = 5

X_ERROR = 6

ENQUEUE_ERROR = 7

OTHERS = 8.

.

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. " SEND_FILE_AS_EMAIL_ATTACHMENT

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM INITIATE_MAIL_EXECUTE_PROGRAM .

WAIT UP TO 2 SECONDS.

SUBMIT RSCONN01 WITH MODE = 'INT'

WITH OUTPUT = 'X'

AND RETURN.

ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

&----


*& Form MAIL_TO_SM

&----


  • text

----


  • -->P_HD_MAIL_ID_ZSMCODE text

----


FORM MAIL_TO_SM USING P_ZEMAIL_ID

P_ZSMCODE.

T_RECEIVERS-RECEIVER = P_ZEMAIL_ID.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

T_RECEIVERS-RECEIVER = 'manjusha.shembekar@bilcare.com'.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

T_RECEIVERS-RECEIVER = 'manjeet.singh@bilcare.com'.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

DATA : ORDER_QTY(12),RATE(10),BAL_QTY(12),PODT(10),ORDDT(10),CUST_REQ_DT(10),

SCH_DT(10).

CONCATENATE 'SALES MANAGER' 'SUPP.MANAGER' 'SOLD TO PARTY NAME' 'SOLD TO PARTY DEST.'

'SHIP TO PARTY NAME' 'SHIP TO PARTY DEST.' 'CUST.CLASS' 'CUST PO#'

'CUST PO DATE' 'OA NO' 'OA DATE' 'MAT.CODE' 'MAT.DESC.'

'MAT.GROUP' 'COLOR' 'COMPLEX' 'WIDTH' 'CUST MAT.NO.'

'ORDER QTY' 'UOM' 'RATE/KG' 'CURRENCY' 'CUST REQ.DATE' 'BRAND NAME'

'SCHEDULE DATE' 'DELAY DAYS' 'BALANCE QTY.' ''

INTO STR_VAL SEPARATED BY CON_TAB.

CONCATENATE CON_CRET STR_VAL INTO STR_VAL.

CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

TEXT = STR_VAL

  • IMPORTING

  • LENGTH =

TABLES

FTEXT_TAB = IT_ATTACH .

CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

LOOP AT GT_FINAL_DATA WHERE ZE_KUNNR = P_ZSMCODE.

CLEAR: ORDER_QTY(12),RATE(10),BAL_QTY(12),PODT(10),ORDDT(10),CUST_REQ_DT(10),

SCH_DT(10).

ORDER_QTY = GT_FINAL_DATA-KWMENG.

RATE = GT_FINAL_DATA-KBETR.

BAL_QTY = GT_FINAL_DATA-BAL_QTY.

CONCATENATE GT_FINAL_DATA-BSTDK6(2) '.' GT_FINAL_DATA-BSTDK4(2) '.'

GT_FINAL_DATA-BSTDK+0(4) INTO PODT.

CONCATENATE GT_FINAL_DATA-ERDAT6(2) '.' GT_FINAL_DATA-ERDAT4(2) '.'

GT_FINAL_DATA-ERDAT+0(4) INTO ORDDT.

CONCATENATE GT_FINAL_DATA-ZZCUST_REQDAT6(2) '.' GT_FINAL_DATA-ZZCUST_REQDAT4(2) '.'

GT_FINAL_DATA-ZZCUST_REQDAT+0(4) INTO CUST_REQ_DT.

CONCATENATE GT_FINAL_DATA-EDATU6(2) '.' GT_FINAL_DATA-EDATU4(2) '.'

GT_FINAL_DATA-EDATU+0(4) INTO SCH_DT.

CONCATENATE GT_FINAL_DATA-ZE_NAME GT_FINAL_DATA-ZS_NAME GT_FINAL_DATA-NAME

GT_FINAL_DATA-ORT01 GT_FINAL_DATA-S_NAME GT_FINAL_DATA-S_ORT01

GT_FINAL_DATA-KLABC GT_FINAL_DATA-BSTNK PODT

GT_FINAL_DATA-VBELN ORDDT

GT_FINAL_DATA-MATNR GT_FINAL_DATA-MAKTG GT_FINAL_DATA-MVGR1

GT_FINAL_DATA-COLOR GT_FINAL_DATA-COMPLEX GT_FINAL_DATA-WIDTH

GT_FINAL_DATA-ZZKDMAT ORDER_QTY GT_FINAL_DATA-MEINS

RATE GT_FINAL_DATA-WAERS CUST_REQ_DT

GT_FINAL_DATA-ZZBRAND SCH_DT GT_FINAL_DATA-DAYS

BAL_QTY '' INTO STR_VAL SEPARATED BY CON_TAB.

CONCATENATE CON_CRET STR_VAL INTO STR_VAL.

CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

TEXT = STR_VAL

  • IMPORTING

  • LENGTH =

TABLES

FTEXT_TAB = IT_ATTACH .

CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

  • INTO IT_ATTACH SEPARATED BY CON_TAB.

  • APPEND IT_ATTACH.

MOVE-CORRESPONDING : GT_FINAL_DATA TO MAIL_TAB.

APPEND MAIL_TAB.CLEAR MAIL_TAB.

ENDLOOP.

IF SY-SUBRC NE 0.

CLEAR :T_RECEIVERS,IT_ATTACH.

REFRESH :T_RECEIVERS,IT_ATTACH.

ENDIF.

IF NOT IT_ATTACH[] IS INITIAL.

PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT

TABLES IT_MESSAGE

IT_ATTACH

USING 'Pending Sale Order Rpt.'

'XLS'

'Order'

' '

' '

' '

CHANGING GD_ERROR

GD_RECIEVER.

PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

ENDIF.

ENDFORM. " MAIL_TO_SM

&----


*& Form MAIL_TO_SP

&----


  • text

----


  • -->P_SP_MAIL_ID_ZSPCODE text

----


FORM MAIL_TO_SP USING P_ZEMAIL_ID

P_ZSPCODE.

T_RECEIVERS-RECEIVER = P_ZEMAIL_ID.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

T_RECEIVERS-RECEIVER = 'manjusha.shembekar@bilcare.com'.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

T_RECEIVERS-RECEIVER = 'manjeet.singh@bilcare.com'.

T_RECEIVERS-REC_TYPE = 'U'.

T_RECEIVERS-COM_TYPE = 'INT'.

T_RECEIVERS-NOTIF_DEL = 'X'.

T_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND T_RECEIVERS.

DATA : ORDER_QTY(12),RATE(10),BAL_QTY(12),PODT(10),ORDDT(10),CUST_REQ_DT(10),

SCH_DT(10).

CONCATENATE 'SALES MANAGER' 'SUPP.MANAGER' 'SOLD TO PARTY NAME' 'SOLD TO PARTY DEST.'

'SHIP TO PARTY NAME' 'SHIP TO PARTY DEST.' 'CUST.CLASS' 'CUST PO#'

'CUST PO DATE' 'OA NO' 'OA DATE' 'MAT.CODE' 'MAT.DESC.'

'MAT.GROUP' 'COLOR' 'COMPLEX' 'WIDTH' 'CUST MAT.NO.'

'ORDER QTY' 'UOM' 'RATE/KG' 'CURRENCY' 'CUST REQ.DATE' 'BRAND NAME'

'SCHEDULE DATE' 'DELAY DAYS' 'BALANCE QTY.' ''

INTO STR_VAL SEPARATED BY CON_TAB.

CONCATENATE CON_CRET STR_VAL INTO STR_VAL.

CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

TEXT = STR_VAL

  • IMPORTING

  • LENGTH =

TABLES

FTEXT_TAB = IT_ATTACH .

CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

LOOP AT GT_FINAL_DATA WHERE ZS_KUNNR = P_ZSPCODE.

CLEAR: ORDER_QTY(12),RATE(10),BAL_QTY(12),PODT(10),ORDDT(10),CUST_REQ_DT(10),

SCH_DT(10).

ORDER_QTY = GT_FINAL_DATA-KWMENG.

RATE = GT_FINAL_DATA-KBETR.

BAL_QTY = GT_FINAL_DATA-BAL_QTY.

CONCATENATE GT_FINAL_DATA-BSTDK6(2) '.' GT_FINAL_DATA-BSTDK4(2) '.'

GT_FINAL_DATA-BSTDK+0(4) INTO PODT.

CONCATENATE GT_FINAL_DATA-ERDAT6(2) '.' GT_FINAL_DATA-ERDAT4(2) '.'

GT_FINAL_DATA-ERDAT+0(4) INTO ORDDT.

CONCATENATE GT_FINAL_DATA-ZZCUST_REQDAT6(2) '.' GT_FINAL_DATA-ZZCUST_REQDAT4(2) '.'

GT_FINAL_DATA-ZZCUST_REQDAT+0(4) INTO CUST_REQ_DT.

CONCATENATE GT_FINAL_DATA-EDATU6(2) '.' GT_FINAL_DATA-EDATU4(2) '.'

GT_FINAL_DATA-EDATU+0(4) INTO SCH_DT.

CONCATENATE GT_FINAL_DATA-ZE_NAME GT_FINAL_DATA-ZS_NAME GT_FINAL_DATA-NAME

GT_FINAL_DATA-ORT01 GT_FINAL_DATA-S_NAME GT_FINAL_DATA-S_ORT01

GT_FINAL_DATA-KLABC GT_FINAL_DATA-BSTNK PODT

GT_FINAL_DATA-VBELN ORDDT

GT_FINAL_DATA-MATNR GT_FINAL_DATA-MAKTG GT_FINAL_DATA-MVGR1

GT_FINAL_DATA-COLOR GT_FINAL_DATA-COMPLEX GT_FINAL_DATA-WIDTH

GT_FINAL_DATA-ZZKDMAT ORDER_QTY GT_FINAL_DATA-MEINS

RATE GT_FINAL_DATA-WAERS CUST_REQ_DT

GT_FINAL_DATA-ZZBRAND SCH_DT GT_FINAL_DATA-DAYS

BAL_QTY '' INTO STR_VAL SEPARATED BY CON_TAB.

CONCATENATE CON_CRET STR_VAL INTO STR_VAL.

CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

TEXT = STR_VAL

  • IMPORTING

  • LENGTH =

TABLES

FTEXT_TAB = IT_ATTACH .

CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

  • INTO IT_ATTACH SEPARATED BY CON_TAB.

  • APPEND IT_ATTACH.

MOVE-CORRESPONDING : GT_FINAL_DATA TO MAIL_TAB.

APPEND MAIL_TAB.CLEAR MAIL_TAB.

ENDLOOP.

IF SY-SUBRC NE 0.

CLEAR :T_RECEIVERS,IT_ATTACH.

REFRESH :T_RECEIVERS,IT_ATTACH.

ENDIF.

IF NOT IT_ATTACH[] IS INITIAL.

PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT

TABLES IT_MESSAGE

IT_ATTACH

USING 'Pending Sale Order Rpt.'

'XLS'

'Order'

' '

' '

' '

CHANGING GD_ERROR

GD_RECIEVER.

PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

ENDIF.

ENDFORM. " MAIL_TO_SP

&----


*& Form NAME_DATA

&----


  • text

----


  • -->P_GT_VBAP_VBELN text

----


FORM NAME_DATA USING P_GT_VBAP_VBELN TYPE VBELN CHANGING T_FLAG.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'ZA'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ZA_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-ZA_NAME = GT_KNA1_1-NAME1.

T_FLAG ='XX'.

ENDIF.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'ZE'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ZE_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-ZE_NAME = GT_KNA1_1-NAME1.

T_FLAG ='XX'.

ENDIF.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'ZI'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ZI_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-ZI_NAME = GT_KNA1_1-NAME1.

T_FLAG ='XX'.

ENDIF.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'ZR'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ZR_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-ZR_NAME = GT_KNA1_1-NAME1.

T_FLAG ='XX'.

ENDIF.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'ZS'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-ZS_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-ZS_NAME = GT_KNA1_1-NAME1.

T_FLAG ='XX'.

ENDIF.

READ TABLE GT_VBPA WITH KEY VBELN = P_GT_VBAP_VBELN

PARVW = 'WE'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-S_KUNNR = GT_VBPA-KUNNR.

READ TABLE GT_KNA1_1 WITH KEY KUNNR = GT_VBPA-KUNNR.

GT_FINAL_DATA-S_NAME = GT_KNA1_1-NAME1.

GT_FINAL_DATA-S_ORT01 = GT_KNA1_1-ORT01.

T_FLAG ='XX'.

ENDIF.

ENDFORM. " NAME_DATA

&----


*& Form VALUE_DATA

&----


  • text

----


  • -->P_GT_VBAK_KNUMV text

  • -->P_GT_VBAP_POSNR text

----


FORM VALUE_DATA USING P_GT_VBAK_KNUMV LIKE VBAK-KNUMV

P_GT_VBAP_POSNR LIKE VBAP-POSNR.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'ZBAP'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-B_VALUE = GT_KONV-KWERT.

GT_FINAL_DATA-KBETR = GT_KONV-KBETR. " Rate per KG

GT_FINAL_DATA-WAERS = GT_KONV-WAERS. "currency

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JEXP'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-EX_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JEDC'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-EC_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JEDH'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-HE_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JIVP'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-VAT_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JIVC'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-CST_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'ZCOM'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-C_VALUE = GT_KONV-KWERT.

ENDIF.

READ TABLE GT_KONV WITH KEY KNUMV = P_GT_VBAK_KNUMV

KPOSN = P_GT_VBAP_POSNR

KSCHL = 'JFRE'.

IF SY-SUBRC = 0.

GT_FINAL_DATA-F_VALUE = GT_KONV-KWERT.

ENDIF.

ENDFORM. " VALUE_DATA</b>

Points will be rewarded...

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question