Go on link..

link us with ...

Thursday, December 30, 2010

BDC Program for Transaction MB1A

*---------------------------------------------------------------------*
* Report ZVVF_MR323_BDCMB1A *
*---------------------------------------------------------------------*
* *
* MODULE : Material Management *
* *
*---------------------------------------------------------------------*
* Objective : BDC Program for Transaction MB1A.The Program will be *
* called from Module-pool Program ZVVF_MM032_PHYINV *
* when the user selects option 1)Goods Issue to Process*
* order or 2)Return from Process Order. *
* Program : Update Tables (X) Download Data ( ) Outputs List ( )*
* Technical Specs No : *
* Date Created : *
* Author : *
* Location : *
* LDB : *
* *
*---------------------------------------------------------------------*
REPORT ZVVF_MR323_BDCMB1A.

*---------------------------------------------------------------------*
* Structures Starts with WA_ *
*---------------------------------------------------------------------*
DATA: BEGIN of WA_RECORD,
BLDAT(010), "Document Date
BUDAT(010), "Posting Date
BWARTWA(003), "Movement Type
WERKS(004), "Plant
LGORT(004), "Storage Location
XFULL,
AUFNR(012), "Process Order Number
XSELK(001) VALUE 'X', "CheckBox
ERFMG(013), "Quantity
ERFME(03), "Unit Of Entry
CHARG(010), "Batch
END of WA_RECORD.

DATA : BEGIN OF WA_GR,
AUFNR TYPE AUFNR,
CHARG TYPE CHARG_D,
INSMK TYPE MENGE_D,
MEINS TYPE MEINS,
END OF WA_GR.

*---------------------------------------------------------------------*
* Internal Table Starts with IT_ *
*---------------------------------------------------------------------*
DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: IT_RECORD LIKE WA_RECORD OCCURS 0 WITH HEADER LINE.
DATA: IT_MSG TYPE TABLE OF BDCMSGCOLL.
DATA: IT_GR LIKE WA_GR OCCURS 0 WITH HEADER LINE.

*---------------------------------------------------------------------*
* Data Starts with W_ *
*---------------------------------------------------------------------*
DATA: W_DATE(10) TYPE C,
W_EXTPERIOD TYPE TPRG-PRGBZ,
W_INTPERIOD TYPE TPRG-PRGRS VALUE 1,
W_MATNR TYPE MATNR,
W_BWART TYPE BWART,
W_WERKS TYPE WERKS_D,
W_LGORT TYPE LGORT_D.

*---------------------------------------------------------------------*
* START OF SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
CALL FUNCTION 'PERIOD_AND_DATE_CONVERT_OUTPUT'
EXPORTING
* COUNTRY = ' '
INTERNAL_DATE = SY-DATUM
INTERNAL_PERIOD = W_INTPERIOD
* LANGUAGE = SYST-LANGU
* I_PERIV =
* I_WERKS =
* I_MRPPP =
IMPORTING
EXTERNAL_DATE = W_DATE
EXTERNAL_PERIOD = W_EXTPERIOD
* EXTERNAL_PRINTTEXT =
* EXCEPTIONS
* DATE_INVALID = 1
* PERIODE_INVALID = 2
* OTHERS = 3
.

IMPORT IT_GR FROM MEMORY ID 'MM032_TABLE'.
IMPORT MATNR TO W_MATNR
BWART TO W_BWART
WERKS TO W_WERKS
LGORT TO W_LGORT
FROM MEMORY ID 'MM032_MI10'.
import w_mtype to w_bwart from memory id 'MM032_MB1AD'.


LOOP AT IT_GR INTO WA_GR.
WA_RECORD-BLDAT = W_DATE.
WA_RECORD-BUDAT = W_DATE.
WA_RECORD-BWARTWA = W_BWART.
WA_RECORD-WERKS = W_WERKS.
WA_RECORD-LGORT = W_LGORT.
WA_RECORD-AUFNR = WA_GR-AUFNR.
WA_RECORD-XSELK = 'X'.
WA_RECORD-ERFMG = WA_GR-INSMK.
WA_RECORD-CHARG = WA_GR-CHARG.
WA_RECORD-ERFME = WA_GR-MEINS.
APPEND WA_RECORD TO IT_RECORD.
ENDLOOP.

LOOP AT IT_RECORD.
perform bdc_dynpro using 'SAPMM07M' '0400'.
perform bdc_field using 'BDC_CURSOR'
'RM07M-LGORT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MKPF-BLDAT'
IT_RECORD-BLDAT.
perform bdc_field using 'MKPF-BUDAT'
IT_RECORD-BUDAT.
perform bdc_field using 'RM07M-BWARTWA'
IT_RECORD-BWARTWA.
perform bdc_field using 'RM07M-WERKS'
IT_RECORD-WERKS.
perform bdc_field using 'RM07M-LGORT'
IT_RECORD-LGORT.
perform bdc_field using 'XFULL'
'X'.
perform bdc_field using 'RM07M-WVERS2'
'X'.

perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-CHARG(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MSEG-MATNR(01)'
W_MATNR.
perform bdc_field using 'MSEG-ERFMG(01)'
IT_RECORD-ERFMG.
perform bdc_field using 'MSEG-ERFME(01)'
IT_RECORD-ERFME.
perform bdc_field using 'MSEG-CHARG(01)'
IT_RECORD-CHARG.

perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-AUFNR'
IT_RECORD-AUFNR.

perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-AUFNR'
IT_RECORD-AUFNR.

call transaction 'MB1A' using IT_bdcdata mode 'E' update 'A'
messages into it_msg.

ENDLOOP.

*----------------------------------------------------------------------*
* FORM Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. "BDC_DYNPRO

*----------------------------------------------------------------------*
* FORM Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> ''.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDIF.
ENDFORM. "BDC_FIELD

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)