SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Batch-input for MMRV



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 160
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Sep 02, 2010 3:02 pm    Post subject: Batch-input for MMRV Reply with quote

Code:
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.                                                    "SCREEN1
***********************************************************************
* 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.                                                    "SCREEN2

***********************************************************************
* 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.                    "CLOSE-SESS

***********************************************************************
* 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.                    "PRN_ULTAB

***********************************************************************
* 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.                    "CRE-BATCH-SESS

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.