Posted: Sat Oct 27, 2007 4:21 pm Post subject: Display Quotations in Hierarchy ALV
Author: Kiran Kumar Somaroutu
Submitted: July 10, 2007
Description:
The below code involves Hierarchy Sequential ALV, BDC, BAPI and also explains about the interactivity of the ALV.
This program is used to display Quotations in Hierarchy ALV. Provision is given to select some of the Quotations and use the interactive button to create Condition Records based on the quotation data.
Code:
REPORT ZSPRENH069 NO STANDARD PAGE HEADING.
TYPE-POOLS : SLIS. "Global Type for ALV
************************************************************************
* T Y P E S *
************************************************************************
TYPES: BEGIN OF TY_VB_AKAP,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
POSNR TYPE POSNR_VA, "Item Number
MATNR TYPE MATNR, "Material Number
PMATN TYPE PMATN, "Pricing Reference Material/Newly Created Material
KWMENG TYPE KWMENG, "Cumulative Order Qty. in Sales Units
VRKME TYPE VRKME, "Sales Unit
* NETPR TYPE NETPR, "Net Price
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
VKAUS TYPE ABRVW, "Usage Indicator
END OF TY_VB_AKAP, BEGIN OF TY_MARA,
MATNR TYPE MATNR, "Material Number
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
END OF TY_MARA, BEGIN OF TY_MVKE,
MATNR TYPE MATNR, "Material Number
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KONDM TYPE KONDM, "Material Pricing Group
END OF TY_MVKE, BEGIN OF TY_VBKD,
VBELN TYPE VBELN_VA, "Sales Document
POSNR TYPE POSNR_VA, "Item Number
BSTKD_E TYPE BSTKD_E, "Used to capture New Material Number
END OF TY_VBKD, BEGIN OF TY_IHEADER,
SELECT(1) TYPE C, "Check Box
VBELN TYPE VBELN, "Sales Document
KUNNR TYPE KUNAG, "Sold-to Party
END OF TY_IHEADER, BEGIN OF TY_MESSAGE1,
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KUNNR TYPE KUNAG, "Customer number
KONDM TYPE KONDM, "Material pricing group
ZCOUNT(2) TYPE N, "Zcount
MSGTYP(1) TYPE C, "Message type
TEXT(150) TYPE C, "Message text
END OF TY_MESSAGE1, BEGIN OF TY_MESSAGE2,
VKORG TYPE VKORG, "Sales Organization
VTWEG TYPE VTWEG, "Distribution Channel
KUNNR TYPE KUNAG, "Customer number
MATNR TYPE MATNR, "Material Number
MSGTYP(1) TYPE C, "Message type
TEXT(150) TYPE C, "Message text
END OF TY_MESSAGE2, BEGIN OF TY_IFINAL,
VBELN TYPE VBELN_VA, "Sales Document
KWMENG TYPE KWMENG, "Cumulative Order Qty. in Sales Units
POSNR TYPE POSNR_VA, "Item Number
KUNNR TYPE KUNAG, "Sold-to party
MATNR TYPE MATNR, "Material Number
VRKME TYPE VRKME, "Sales Unit
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
VKAUS TYPE ABRVW, "Usage Indicator
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
PMATN TYPE PMATN, "Pricing Reference Material/Newly Created Material
KONDM TYPE KONDM, "Material Pricing Group
END OF TY_IFINAL, BEGIN OF TY_ACC1,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
KONDM TYPE KONDM, "Material Pricing Group
ZCOUNT(2) TYPE N, "ZCount indicator
KSTBM TYPE KSTBM, "Quantity
VRKME TYPE VRKME, "Sales Unit
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
ERROR(1) TYPE N, "Error Field
END OF TY_ACC1, BEGIN OF TY_ACC2,
VBELN TYPE VBELN_VA, "Sales Document
KUNNR TYPE KUNAG, "Sold-to party
MATNR TYPE MATNR, "Material Number
KSTBM TYPE KSTBM, "Cumulative Order Qty. in Sales Units
ZZTECHSPEC TYPE ZTECHSPEC, "Technical Specification
VRKME TYPE VRKME, "Sales Unit
KZWI1 TYPE KZWI1, "Sub Total 1 from pricing procedure for condition
ERROR(1) TYPE N, "Error field
END OF TY_ACC2.
************************************************************************
* D A T A *
************************************************************************
* Internal Table Declarations
*****************************
DATA: T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV, "Fieldcatalog IT
T_EVENTS TYPE SLIS_T_EVENT, "Event IT
T_HEADER TYPE SLIS_T_LISTHEADER, "Header IT
T_VB_AKAP TYPE STANDARD TABLE OF TY_VB_AKAP, "To hold records from VBAK & VBAP Table
T_MARA TYPE STANDARD TABLE OF TY_MARA, "To hold records from MARA Table
T_MVKE TYPE STANDARD TABLE OF TY_MVKE, "To hold records from MVKE Table
T_VBKD TYPE STANDARD TABLE OF TY_VBKD, "To hold records from VBKD Table
T_IHEADER TYPE STANDARD TABLE OF TY_IHEADER, "To hold records from VBAK Table
T_IFINAL TYPE STANDARD TABLE OF TY_IFINAL, "To hold cumulative data for ALV
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA, "IT for bdcdata
T_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL, "IT for error messages
T_MESSAGE1 TYPE STANDARD TABLE OF TY_MESSAGE1, "IT for conditions1 messages
T_MESSAGE2 TYPE STANDARD TABLE OF TY_MESSAGE2, "IT for conditions2 messages
T_ACC2 TYPE STANDARD TABLE OF TY_ACC2, "IT for holding data for Second Access Sequence Processing
T_ACC1 TYPE STANDARD TABLE OF TY_ACC1, "IT for holding data for First Access Sequence Processing
T_SELECT TYPE STANDARD TABLE OF RSPARAMS, "IT for holding data related to the selection screen
* Work area Declarations
************************
W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV, "Fieldcatalog WA
W_EVENT TYPE SLIS_ALV_EVENT, "Event WA
W_HEADER TYPE SLIS_LISTHEADER, "Header WA
W_LAYOUT TYPE SLIS_LAYOUT_ALV, "Layout WA
W_KEYINFO TYPE SLIS_KEYINFO_ALV, "Key Information WA
W_VB_AKAP TYPE TY_VB_AKAP, "To hold records from T_VB_AKAP
W_MARA TYPE TY_MARA, "To hold records from T_MARA
W_MVKE TYPE TY_MVKE, "To hold records from T_MVKE
W_VBKD TYPE TY_VBKD, "To hold records from T_VBKD
W_IHEADER TYPE TY_IHEADER, "To hold records from T_IHEADER
W_IFINAL TYPE TY_IFINAL, "To hold records from T_IFINAL
W_PARAMS TYPE CTU_PARAMS, "CTU Params
W_BDCDATA TYPE BDCDATA, "Work Area for BDCDATA
W_BDCMSGCOLL TYPE BDCMSGCOLL, "Work Area to collect BDC Messages
W_MESSAGE1 TYPE TY_MESSAGE1, "WA for price conditions1 messages
W_MESSAGE2 TYPE TY_MESSAGE2, "WA for price conditions2 messages
W_ACC2 TYPE TY_ACC2, "WA for holding records from T_ACC2
W_ACC1 TYPE TY_ACC1, "WA for holding records from T_ACC1
* Variable declarations
***********************
G_AUDAT TYPE AUDAT, "Document Date (Date Received/Sent)
G_VBELN TYPE VBELN_VA, "Sales Document
G_KUNNR TYPE KUNAG, "Sold-to party
G_MATNR TYPE MATNR, "Material Number
G_REPID TYPE SY-REPID, "Program Name
G_MESSAGE(73) TYPE C, "To Capture Message
G_FLAG1(1) TYPE C, "Flag
G_ANSWER(1) TYPE C. "Optional Button
* Constant declarations
***********************
CONSTANTS:
C_A(1) TYPE C VALUE 'A', "Constant Value A
C_S(1) TYPE C VALUE 'S', "Constant Value S
C_U(1) TYPE C VALUE 'U', "Constant Value U
C_X(1) TYPE C VALUE 'X', "Constant Value X
C_E(1) TYPE C VALUE 'E', "Constant Value E
C_I(1) TYPE C VALUE 'I', "Constant Value I
C_R(1) TYPE C VALUE 'R', "Constant Value R
C_B(1) TYPE C VALUE 'B', "Document Category is Quotation
C_HTNAME(10) TYPE C VALUE 'T_IHEADER', "Internal table for Header Data
C_ITNAME(10) TYPE C VALUE 'T_IFINAL', "Internal Table with processed data
C_Q2(2) TYPE C VALUE 'Q2', "Constant Order Reason Q2
C_100(3) TYPE C VALUE '100', "Popup screen
* C_046(3) TYPE C VALUE '046', "Value 046
* C_047(3) TYPE C VALUE '047', "Value 047
C_25(2) TYPE C VALUE '25', "Popup screen
C_5(1) TYPE C VALUE '5', "Popup screen
C_1 TYPE I VALUE 1, "Value 1 for Error Denotion
C_2 TYPE I VALUE 2, "Value 2 for Error Denotion
C_3 TYPE I VALUE 3, "Value 3 for BDC Error Denotion
C_1000(4) TYPE N VALUE 1000, "Value 1000
C_01(2) TYPE N VALUE '01', "Value 01 for Zcount
C_VK11(4) TYPE C VALUE 'VK11', "Transaction VK11
C_DYNBEGIN(1) TYPE C VALUE 'X', "Indicator
C_UPDATE(1) TYPE C VALUE 'S', "Update
C_DISMODE(1) TYPE C VALUE 'N', "Display
C_ZBPR(4) TYPE C VALUE 'ZBPR', "Condition Type ZBPR
C_ERROR(5) TYPE C VALUE 'ERROR'. "Error screen title
************************************************************************
* S E L E C T O P T I O N S & P A R A M E T E R S *
************************************************************************
* Selection-screen Block 1
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_VKORG TYPE VKORG OBLIGATORY, "Sales Organization
P_VTWEG TYPE VTWEG OBLIGATORY, "Distribution Channel
P_SPART TYPE SPART DEFAULT '00'. "Division
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: S_AUDAT FOR G_AUDAT, "Document Date (Date Received/Sent)
S_VBELN FOR G_VBELN, "Sales Document
S_KUNNR FOR G_KUNNR, "Sold-to party
S_MATNR FOR G_MATNR. "Material Number
PARAMETERS: P_VKAUS(2) TYPE N. "Usage Indicator
SELECTION-SCREEN END OF BLOCK BLK2.
************************************************************************
* I N I T I A L I Z A T I O N *
************************************************************************
INITIALIZATION.
CLEAR : G_REPID. "Program Name
G_REPID = SY-REPID. "Program Name
************************************************************************
* A T S E L E C T I O N S C R E E N *
************************************************************************
AT SELECTION-SCREEN.
************************************************************************
* S T A R T O F S E L E C T I O N *
************************************************************************
START-OF-SELECTION.* Data Selection
PERFORM DATA_RETRIEVAL.* Build Field Catalog
PERFORM BUILD_FIELDCATALOG.* Bulid layout
PERFORM BUILD_LAYOUT.* Build Events
PERFORM BUILD_EVENTS.* Captures the Values of Selection Screen
PERFORM CAPTURE_SCREEN.
************************************************************************
* E N D O F S E L E C T I O N *
************************************************************************
END-OF-SELECTION.* Display List
PERFORM DISPLAY_ALV_REPORT.
************************************************************************
* F O R M S *
************************************************************************
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieves Data for ALV Display
*----------------------------------------------------------------------*
FORM DATA_RETRIEVAL .
DATA : L_VKAUS TYPE VKAUS. "Variable to hold Usage Indicator
CLEAR L_VKAUS. SELECT VBELN
KUNNR
INTO CORRESPONDING FIELDS OF TABLE T_IHEADER
FROM VBAK
WHERE VBELN IN S_VBELN
AND KUNNR IN S_KUNNR
AND VKORG EQ P_VKORG
AND AUDAT IN S_AUDAT
AND VTWEG EQ P_VTWEG
AND SPART EQ P_SPART
AND AUGRU EQ C_Q2
AND VBTYP EQ C_B.
IF NOT T_IHEADER IS INITIAL.
IF NOT P_VKAUS IS INITIAL OR P_VKAUS NE C_1.
CONCATENATE 'C' P_VKAUS INTO L_VKAUS.
SELECT A~VBELN
A~KUNNR
B~POSNR
B~MATNR
B~PMATN
B~KWMENG
B~VRKME
* B~NETPR
B~KZWI1
B~VKAUS
INTO TABLE T_VB_AKAP
FROM VBAK AS A
JOIN VBAP AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN T_IHEADER
WHERE A~VBELN EQ T_IHEADER-VBELN
AND B~MATNR IN S_MATNR
AND B~VKAUS EQ L_VKAUS.
ELSE.
SELECT A~VBELN
A~KUNNR
B~POSNR
B~MATNR
B~PMATN
B~KWMENG
B~VRKME
* B~NETPR
B~KZWI1
B~VKAUS
INTO TABLE T_VB_AKAP
FROM VBAK AS A
JOIN VBAP AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN T_IHEADER
WHERE A~VBELN EQ T_IHEADER-VBELN
AND B~MATNR IN S_MATNR.
ENDIF.
IF NOT T_VB_AKAP IS INITIAL.
SELECT VBELN
POSNR
BSTKD_E
INTO TABLE T_VBKD
FROM VBKD
FOR ALL ENTRIES IN T_VB_AKAP
WHERE VBELN EQ T_VB_AKAP-VBELN
AND POSNR EQ T_VB_AKAP-POSNR.
ENDIF.
SORT T_VBKD BY VBELN POSNR.
CLEAR W_VB_AKAP.
* After much of coding was completed, Usage of PMATN was dropped and
* the first eighteen characters of the field BSTKD was proposed for usage
* Hence PMATN is overwritten by BSTKD value in the below loop
LOOP AT T_VB_AKAP INTO W_VB_AKAP.
CLEAR: W_VBKD,
W_VB_AKAP-PMATN.
READ TABLE T_VBKD INTO W_VBKD
WITH KEY VBELN = W_VB_AKAP-VBELN
POSNR = W_VB_AKAP-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_VB_AKAP-PMATN = W_VBKD-BSTKD_E+0(18).
ENDIF. MODIFY T_VB_AKAP FROM W_VB_AKAP TRANSPORTING PMATN.
CLEAR W_VB_AKAP.
ENDLOOP.
IF NOT T_VB_AKAP IS INITIAL.
SELECT MATNR
ZZTECHSPEC
INTO TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-MATNR.
IF SY-SUBRC EQ 0.
SORT T_MARA BY MATNR.
ENDIF. "Checking SY-SUBRC for T_MARA
SELECT MATNR
ZZTECHSPEC
APPENDING TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-PMATN.
IF SY-SUBRC EQ 0.
SORT T_MARA BY MATNR.
ENDIF. "Checking SY-SUBRC for T_MARA
SELECT MATNR
VKORG
VTWEG
KONDM
INTO TABLE T_MVKE
FROM MVKE
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-PMATN.
IF SY-SUBRC EQ 0.
SORT T_MVKE BY MATNR VKORG VTWEG.
ENDIF. "Checking SY-SUBRC for T_MVKE
SELECT MATNR
VKORG
VTWEG
KONDM
APPENDING TABLE T_MVKE
FROM MVKE
FOR ALL ENTRIES IN T_VB_AKAP
WHERE MATNR EQ T_VB_AKAP-MATNR.
IF SY-SUBRC EQ 0.
SORT T_MVKE BY MATNR VKORG VTWEG.
ENDIF. "Checking SY-SUBRC for T_MVKE
ENDIF. " FOR T_VB_AKAP NOT INITIAL.
ENDIF. " FOR T_IHEADER NOT INITIAL.
CLEAR: W_VB_AKAP,
W_IFINAL.
LOOP AT T_VB_AKAP INTO W_VB_AKAP.
W_IFINAL-VBELN = W_VB_AKAP-VBELN.
W_IFINAL-KUNNR = W_VB_AKAP-KUNNR.
W_IFINAL-POSNR = W_VB_AKAP-POSNR.
W_IFINAL-MATNR = W_VB_AKAP-MATNR.
W_IFINAL-PMATN = W_VB_AKAP-PMATN.
W_IFINAL-KWMENG = W_VB_AKAP-KWMENG.
W_IFINAL-VRKME = W_VB_AKAP-VRKME.
* W_IFINAL-NETPR = W_VB_AKAP-NETPR.
W_IFINAL-KZWI1 = ( W_VB_AKAP-KZWI1 / W_VB_AKAP-KWMENG ) * 1000.
W_IFINAL-VKAUS = W_VB_AKAP-VKAUS.
* Populating Material Pricing Group from New Material Group, if such Group doesn't exist
* Population of Material Pricing Group from Material Number is tried.
* Similar condition does suit for Tech Spec too.
SORT: T_MVKE BY MATNR VKORG VTWEG,
T_MARA BY MATNR.
IF NOT W_VB_AKAP-PMATN IS INITIAL.
CLEAR W_MVKE.
READ TABLE T_MVKE
INTO W_MVKE
WITH KEY MATNR = W_VB_AKAP-PMATN
VKORG = P_VKORG
VTWEG = P_VTWEG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-KONDM = W_MVKE-KONDM.
ENDIF.
READ TABLE T_MARA
INTO W_MARA
WITH KEY MATNR = W_VB_AKAP-PMATN
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
ENDIF. " SY-SUBRC FOR READ TABLE T_MARA*
IF W_MVKE-KONDM IS INITIAL.
ELSE.
* SORT T_MVKE BY MATNR VKORG VTWEG.
CLEAR W_MVKE.
READ TABLE T_MVKE
INTO W_MVKE
WITH KEY MATNR = W_VB_AKAP-MATNR
VKORG = P_VKORG
VTWEG = P_VTWEG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-KONDM = W_MVKE-KONDM.
ENDIF.
READ TABLE T_MARA
INTO W_MARA
WITH KEY MATNR = W_VB_AKAP-MATNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
ENDIF.
" SY-SUBRC FOR READ TABLE T_MARA* ELSE.
*
* W_IFINAL-KONDM = W_MVKE-KONDM.
*
ENDIF.
" IS INITIAL CHECK FOR W_MVKE-KONDM APPEND W_IFINAL TO T_IFINAL.
CLEAR: W_VB_AKAP,
W_IFINAL.
ENDLOOP.
SORT T_IFINAL BY VBELN.
* Checking whether if there are any header quotations which does not have items against them in item internal table
* if such records exist then, ensuring that such records gets deleted from header too, so that inconsitency is removed.
CLEAR W_IHEADER.
LOOP AT T_IHEADER INTO W_IHEADER.
CLEAR W_IFINAL.
READ TABLE T_IFINAL INTO W_IFINAL WITH KEY VBELN = W_IHEADER-VBELN.
IF SY-SUBRC NE 0.
W_IHEADER-SELECT = C_X.
MODIFY T_IHEADER FROM W_IHEADER TRANSPORTING SELECT.
ENDIF.
ENDLOOP.
DELETE T_IHEADER WHERE SELECT = C_X.
SORT T_IFINAL BY VBELN.
ENDFORM.
" DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
* To build ALV Layout
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT.
CLEAR : W_LAYOUT.
W_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
W_LAYOUT-BOX_TABNAME = C_HTNAME. "tabname for checkbox
W_LAYOUT-BOX_FIELDNAME = 'SELECT'. "fieldname for checkbox
CLEAR : W_KEYINFO.
W_KEYINFO-HEADER01 = 'VBELN'. "Header1 key information
W_KEYINFO-ITEM01 = 'VBELN'. "Item1 key informationENDFORM.
"build_layout
*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
* To build ALV Events
*----------------------------------------------------------------------*
FORM BUILD_EVENTS.
CONSTANTS: C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 1
IMPORTING
ET_EVENTS = T_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC = 0.
READ TABLE T_EVENTS INTO W_EVENT
WITH KEY NAME = C_TOP_OF_PAGE.
IF SY-SUBRC = 0.
MOVE C_TOP_OF_PAGE TO W_EVENT-FORM.
MODIFY T_EVENTS INDEX SY-TABIX
FROM W_EVENT
TRANSPORTING FORM.
ENDIF.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
"build_events
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* To display top of page in ALV Report
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
"#EC CALLED
DATA :
L_VKORG(35) TYPE C, "Sales Organization
L_VTWEG(35) TYPE C, "Distribution Channel
L_SPART(35) TYPE C. "Division*
* Title
* CLEAR W_HEADER.
* W_HEADER-TYP = C_H.
* W_HEADER-INFO = TEXT-003.
* APPEND W_HEADER TO T_HEADER.
* Sales Organization
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-004 P_VKORG INTO L_VKORG.
W_HEADER-INFO = L_VKORG.
APPEND W_HEADER TO T_HEADER.
* Distribution Channel
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-005 P_VTWEG INTO L_VTWEG.
W_HEADER-INFO = L_VTWEG.
APPEND W_HEADER TO T_HEADER.
* Division
CLEAR W_HEADER.
W_HEADER-TYP = C_S.
CONCATENATE TEXT-006 P_SPART INTO L_SPART.
W_HEADER-INFO = L_SPART.
APPEND W_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM.
"top_of_page
*&---------------------------------------------------------------------*
*& Form pf_status
*&---------------------------------------------------------------------*
* To set PF-Status (user interface)
*----------------------------------------------------------------------*
* -->EXTAB The excluding table (function codes)
*----------------------------------------------------------------------*
FORM PF_STATUS "#EC CALLED
USING T_EXTAB TYPE SLIS_T_EXTAB.
"#EC NEEDED SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.
ENDFORM.
"pf_status
*&---------------------------------------------------------------------*
*& Form display_alv_report
*&---------------------------------------------------------------------*
* To display ALV report
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = W_LAYOUT
IT_FIELDCAT = T_FIELDCATALOG
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
I_DEFAULT = C_X
I_SAVE = C_A
* IS_VARIANT =
IT_EVENTS = T_EVENTS[]
* IT_EVENT_EXIT =
I_TABNAME_HEADER = 'T_IHEADER'
I_TABNAME_ITEM = 'T_IFINAL'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
IS_KEYINFO = W_KEYINFO
* IS_PRINT =
* IS_REPREP_ID =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* IR_SALV_HIERSEQ_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB_HEADER = T_IHEADER
T_OUTTAB_ITEM = T_IFINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <0> P_VBELN Quotation Number
*----------------------------------------------------------------------
*FORM CHANGE_SALESDOCUMENT_STATUS USING P_VBELN TYPE VBELN.
DATA :
W_ORDER_HEADER_IN TYPE BAPISDH1,
W_ORDER_HEADER_INX TYPE BAPISDH1X,
W_RETURN TYPE BAPIRET2, "#EC NEEDED
T_ORDER_HEADER_IN TYPE STANDARD TABLE OF BAPISDH1, "#EC NEEDED
T_ORDER_HEADER_INX TYPE STANDARD TABLE OF BAPISDH1X, "#EC NEEDED
T_RETURN TYPE STANDARD TABLE OF BAPIRET2.
CLEAR: W_ORDER_HEADER_IN,
W_ORDER_HEADER_INX.
* LOOP AT T_IHEADER INTO W_IHEADER WHERE SELECT = C_X.
W_ORDER_HEADER_IN-ORD_REASON = 'Q3'.
APPEND W_ORDER_HEADER_IN TO T_ORDER_HEADER_IN.
W_ORDER_HEADER_INX-UPDATEFLAG = C_U.
W_ORDER_HEADER_INX-ORD_REASON = C_X.
APPEND W_ORDER_HEADER_INX TO T_ORDER_HEADER_INX.
*--Bapi to change status of open sales IHEADERs
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = P_VBELN
ORDER_HEADER_IN = W_ORDER_HEADER_IN
ORDER_HEADER_INX = W_ORDER_HEADER_INX
TABLES
RETURN = T_RETURN.
CLEAR W_RETURN.
READ TABLE T_RETURN INTO W_RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY_OK'
EXPORTING
ENDPOS_COL = C_100
ENDPOS_ROW = C_25
STARTPOS_COL = C_5
STARTPOS_ROW = C_5
TITLETEXT = C_ERROR
TABLES
VALUETAB = T_RETURN
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2. IF SY-SUBRC <0>p_fnam Field Name
* -->p_fval Field Value
*----------------------------------------------------------------------*
FORM BDC_FIELD USING P_FNAM TYPE ANY
P_FVAL TYPE ANY.
W_BDCDATA-FNAM = P_FNAM.
W_BDCDATA-FVAL = P_FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
CLEAR W_BDCDATA.
ENDFORM. " bdc_field
*&---------------------------------------------------------------------*
*& Form DISPLAY_RESULT
*&---------------------------------------------------------------------*
* Displays all the messages regarding posting of Condition Records
*----------------------------------------------------------------------*
FORM DISPLAY_RESULT .
* Messages related to the First Access Sequence
IF T_MESSAGE1 IS NOT INITIAL.
WRITE : /70 TEXT-008.
SKIP 2.
SORT T_MESSAGE1 BY VKORG.
WRITE : /9 TEXT-010, 24 TEXT-011, 50 TEXT-012, 70 TEXT-013.
CLEAR G_FLAG1.
LOOP AT T_MESSAGE1 INTO W_MESSAGE1.
AT NEW VKORG.
G_FLAG1 = 'X'.
ENDAT.
AT NEW VTWEG.
G_FLAG1 = 'X'.
ENDAT.
AT NEW KUNNR.
G_FLAG1 = 'X'.
ENDAT.
AT NEW KONDM.
G_FLAG1 = 'X'.
ENDAT.
IF G_FLAG1 = 'X'.
SKIP 1.
WRITE : /9 W_MESSAGE1-VKORG, 24 W_MESSAGE1-VTWEG,
50 W_MESSAGE1-KUNNR, 70 W_MESSAGE1-KONDM. SKIP 1.
WRITE: /9 TEXT-014, 23 TEXT-019, 45 TEXT-015.
ENDIF.
WRITE : /9 W_MESSAGE1-MSGTYP, 23 W_MESSAGE1-ZCOUNT, 45 W_MESSAGE1-TEXT.
CLEAR: G_FLAG1,
W_MESSAGE1.
ENDLOOP.
REFRESH T_MESSAGE1.
ENDIF.* Messages related to the Second Access Sequence
IF T_MESSAGE2 IS NOT INITIAL.
SKIP 2.
WRITE : /70 TEXT-009.
SKIP 2.
SORT T_MESSAGE2 BY VKORG.
WRITE : /9 TEXT-010, 24 TEXT-011, 50 TEXT-012.
CLEAR G_FLAG1.
LOOP AT T_MESSAGE2 INTO W_MESSAGE2.
AT NEW VKORG.
G_FLAG1 = 'X'.
ENDAT. AT NEW VTWEG.
G_FLAG1 = 'X'.
ENDAT. AT NEW KUNNR.
G_FLAG1 = 'X'.
ENDAT.
IF G_FLAG1 = 'X'.
SKIP 1.
WRITE : /9 W_MESSAGE2-VKORG, 24 W_MESSAGE2-VTWEG, 50 W_MESSAGE2-KUNNR.
SKIP 1.
WRITE: /9 TEXT-014, 23 TEXT-020, 45 TEXT-015.
ENDIF.
WRITE : /9 W_MESSAGE2-MSGTYP, 23 W_MESSAGE2-MATNR, 45 W_MESSAGE2-TEXT.
CLEAR: G_FLAG1,
W_MESSAGE2.
ENDLOOP.
REFRESH T_MESSAGE2.
ENDIF.ENDFORM. " DISPLAY_RESULT
*&---------------------------------------------------------------------*
*& Form CAPTURE_SCREEN
*&---------------------------------------------------------------------*
* Captures the Selection Screen Values of the present program
*----------------------------------------------------------------------*
FORM CAPTURE_SCREEN .
DATA L_REPID TYPE SY-REPID.
REFRESH T_SELECT.
L_REPID = SY-REPID.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
CURR_REPORT = L_REPID
* IMPORTING
* SP =
TABLES
SELECTION_TABLE = T_SELECT
EXCEPTIONS
NOT_FOUND = 1
NO_REPORT = 2
OTHERS = 3
.
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. " CAPTURE_SCREEN*/
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 can 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.