Powered By

Free XML Skins for Blogger

Powered by Blogger

Sunday, June 22, 2008

Auto Disallowed Back Posting to Previous Period

***********************************************************************
* AUTO DISALLOWED BACK POSTING TO PREVIOUS PERIOD
***********************************************************************

REPORT ZBDCMMRV.
TABLES: MARV.

* Batch Input Name
PARAMETERS P-BTCHSN(12) DEFAULT 'MMRVCHANGE'.
* Company Code
PARAMETERS P-BUKRS LIKE MARV-BUKRS.
* Auto / Manual run the Batch Input Program
PARAMETERS P-RUN AS CHECKBOX DEFAULT 'X'.

* INTERNAL TABLE FOR DATA
DATA: BEGIN OF ULTAB OCCURS 50,
BUKRS LIKE MARV-BUKRS, "Company Code
END OF ULTAB.

* INTERNAL TABLE FOR BATCH INPUT DATA
DATA: BEGIN OF IPUTTAB OCCURS 50.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF IPUTTAB.

* INTERNAL TABLE FOR BATCH INPUT ERROR MESSAGE.
DATA: BEGIN OF MESSTAB OCCURS 50.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.

DATA: C_TAXKM LIKE MG03STEUER-TAXKM VALUE '1',
W-LINE-NO TYPE I.

REFRESH ULTAB.
SELECT * FROM MARV WHERE BUKRS = P-BUKRS.
ULTAB-BUKRS = MARV-BUKRS.
APPEND ULTAB.

ENDSELECT.

* CHECK WHETHER TABLE IS EMPTY
IF ULTAB[] is initial.
WRITE: / 'TABLE EMPTY'.
ENDIF.

* Create Batch session
PERFORM CRE-BATCH-SESS.

** LOOP TABLE TO CREATE SCREEN INPUT
SORT.
LOOP AT ULTAB.
REFRESH IPUTTAB.
PERFORM SCREEN1.
PERFORM SCREEN2.
PERFORM PRN_ULTAB.
PERFORM CLOSE-SESS.
ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

* END OF MAIN PROGRAM

FORM SCREEN1.
* SCREEN #1: INITAL SCREEN FOR MAINTAINING SOURCE LIST
CLEAR IPUTTAB.
IPUTTAB-PROGRAM = 'SAPMM03Y'.
IPUTTAB-DYNPRO = '100'.
IPUTTAB-DYNBEGIN = 'X'.
APPEND IPUTTAB.

* MMRV ENQUIRY BY COMPANY CODE
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-BUKRS'.
IPUTTAB-FVAL = ULTAB-BUKRS.
APPEND IPUTTAB.

ENDFORM.
***********************************************************************
* FORM : SCREEN1 *
***********************************************************************
FORM SCREEN2.
* MODIFY SCREEN IN MMRV
CLEAR IPUTTAB.
IPUTTAB-PROGRAM = 'SAPMM03Y'.
IPUTTAB-DYNPRO = '110'.
IPUTTAB-DYNBEGIN = 'X'.
APPEND IPUTTAB.

* UNTICK ALLOWED POSTING TO PREVIOUS PERIOD
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-XRUEM'.
IPUTTAB-FVAL = ' '.
APPEND IPUTTAB.

* DISALLOWED BACKPOSTING GENERALLY
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-XRUEV'.
IPUTTAB-FVAL = 'X'.
APPEND IPUTTAB.

* Specify that we are now done with this screen (Save it with F11)
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'BDC_OKCODE'.
IPUTTAB-FVAL = '/11'.
APPEND IPUTTAB.
ENDFORM.

***********************************************************************
* FORM : CLOSE-SESS *
* DESCRIPTION : CLOSE THE SESSION *
***********************************************************************
FORM CLOSE-SESS.
* closing the session.
IF P-RUN = 'X'.
* Auto run the Batch Input Program
CALL TRANSACTION 'MMRV'
USING IPUTTAB
MODE 'E'
UPDATE 'S'
MESSAGES INTO MESSTAB.
ELSE.
* Maual run the Batch Input Program
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MMRV'
TABLES
DYNPROTAB = IPUTTAB.
ENDIF.

ENDFORM.

***********************************************************************
* FORM : PRN-ULTAB *
* DESCRIPTION : PRINT OK TABLE *
***********************************************************************
FORM PRN_ULTAB.
WRITE: / ULTAB-BUKRS.
W-LINE-NO = W-LINE-NO + 1.
WRITE: ' RECORD# ', W-LINE-NO.
ENDFORM.

***********************************************************************
* FORM : CRE-BATCH-SESS *
* DESCRIPTION : CREATE BATCH SESSION *
***********************************************************************
FORM CRE-BATCH-SESS.
** Create BTCI session **
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = P-BTCHSN
USER = SY-UNAME
KEEP = 'X'.
ENDFORM.

No comments:

Archives