BDC code for MM01 Transaction
Hi All,,
Please give Entire BDC code for MM01 Transaction.
i will change as per my requirement.
I think this is already done by some ABAP Consultants.
plz dont give answers like do recording for that transaction MM01. I know recording...
For time constraiint, I have to complete soon.....
Thanks in Advance
BestRegards,
Anil
Hi,
The below code is using the Session Method
report ZDS_BDC_MM01
no standard page heading line-size 255.
include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: XFELD
KZSEL_02_005(001),
* data element: MAKTX
MAKTX_006(040),
* data element: MEINS
MEINS_007(003),
* data element: MAKTX
MAKTX_008(040),
end of record.
*** End generated data section ***
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME ='C:\DHRUV.TXT'
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = RECORD
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*do.
LOOP AT record.
*read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
record-KZSEL_02_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_008.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
*enddo.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
*Messages
* Message class: MS
*613 Please enter a session name and user name
The Below is the coding for the Call Transaction...
report ZDS_BDC_MM01_2
no standard page heading line-size 255.
*include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: MAKTX
MAKTX_005(040),
* data element: MEINS
MEINS_006(003),
* data element: MTPOS_MARA
MTPOS_MARA_007(004),
end of record.
DATA: FLNAME TYPE STRING.
*** End generated data section ***
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*** MESSAGE******
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: MATNR TYPE MARA-MATNR,
END OF MESSTAB.
****END OF MESSAGE****
PARAMETERS: FILENAME TYPE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = FILENAME.
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
FLNAME = FILENAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FLNAME
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = record
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT record.
DATA:
CNT TYPE I.
CNT = CNT + 1.
REFRESH BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_005.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_006.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_007.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
CALL TRANSACTION 'MM01' USING BDCDATA
MODE 'N'
UPDATE 'A'
MESSAGES INTO MESSTAB.
READ TABLE MESSTAB INTO MESSTAB INDEX CNT.
IF MESSTAB-MSGTYP = 'E'.
MESSTAB-MATNR = RECORD-MATNR_001.
MODIFY MESSTAB INDEX CNT FROM MESSTAB. " TRANSPORTING MATNR.
ENDIF.
ENDLOOP.
FORM OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = 'MM01'
USER = SY-UNAME
KEEP = 'X'.
ENDFORM.
FORM BDC_INSERT.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 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.
ENDIF.
ENDFORM.
END-OF-SELECTION.
LOOP AT MESSTAB.
IF MESSTAB-MSGTYP = 'E'.
WRITE:/ 'ERROR OCCURED ON MATNR = ',MESSTAB-MATNR , 'MESSAGE : MATNR ALREADY EXISTS IN MARA!!!'.
ENDIF.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*& Form close_group
* text
* --> p1 text
* <-- p2 text
FORM close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 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. " close_group
*& Form bdc_dynpro
* text
* -->P_0270 text
* -->P_0271 text
FORM bdc_dynpro USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. " bdc_dynpro
*& Form bdc_field
* text
* -->P_0275 text
* -->P_0276 text
FORM bdc_field USING FNAM FVAL.
IF FVAL <> ' '.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. " bdc_field
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
HTH
Regards,
Dhruv Shah
Similar Messages
-
Need BDC code for Call Transaction of VL31N, which creates Inbound del.s,
Hi Experts,
Is any body does have the BDC (CALL TRANSACTION) code for VL31N transaction, where we can crete INBOUND deliveries from Purc Orders.
Actually, currently am doing by using FM - GN_DELIVERY_CREATE, but, its not given me a chance to incorporate BATCH SPLIT functionality. So, decided to go with BDC
1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
3 - BDC code for VL31N tx.
thanq
Edited by: Srinivas on Jul 29, 2008 1:47 PM1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
yes you can do that .
2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
using BDC we can achieve the Barch split functionality.
3 - BDC code for VL31N tx.
Record using SHDB it will give you. -
Hi all,
Can anyone of you provide me complete BDC code for Transaction XD01.
An early reply will be highly appreciated and would be rewarded.
Regards,
NeerajHi Prakash
hope this code will help you.
ABAP BDC SAMPLE CODE XD01
Table/Structure declarations. *
TABLES : KNA1. "Customer master
Constants declarations. *
CONSTANTS : C_MODE VALUE 'A',
C_UPDATE VALUE 'S',
C_X VALUE 'X',
C_SESS TYPE APQI-GROUPID VALUE 'ZCUSTOMER', "Session Name
C_XD01 LIKE TSTC-TCODE VALUE 'XD01'.
Variable declarations. *
DATA : V_FNAME(15) VALUE SPACE, " Name of file to be created
V_FAILREC TYPE I, " No of failed records
V_MSG(255), " Message Text
V_ERRREC TYPE I, " No of failed records
V_LINES TYPE I, " No of records
V_BANKS(15), " Table column BANKS
V_BANKL(15), " Table column BANKL
V_BANKN(15), " Table column BANKN
V_TIDX(2) TYPE N. " Table row index
*-- FLAG DECLARATIONS
DATA : FG_DATA_EXIST VALUE 'X', " Check for data
FG_SESSION_OPEN VALUE ' '. " Check for Session Open
*-- MACRO DEFINITIONS
*-- Macro for BANKS
DEFINE BANKS.
CLEAR V_BANKS.
CONCATENATE 'KNBK-BANKS(' &1 ')' INTO V_BANKS.
CONDENSE V_BANKS.
END-OF-DEFINITION.
*-- Macro for BANKL
DEFINE BANKL.
CLEAR V_BANKL.
CONCATENATE 'KNBK-BANKL(' &1 ')' INTO V_BANKL.
CONDENSE V_BANKL.
END-OF-DEFINITION.
*-- Macro for BANKN
DEFINE BANKN.
CLEAR V_BANKN.
CONCATENATE 'KNBK-BANKN(' &1 ')' INTO V_BANKN.
CONDENSE V_BANKN.
END-OF-DEFINITION.
Structures / Internal table declarations *
*-- Structure to hold BDC data
TYPES : BEGIN OF T_BDCTABLE.
INCLUDE STRUCTURE BDCDATA.
TYPES END OF T_BDCTABLE.
*-- Structure to trap BDC messages
TYPES : BEGIN OF T_MSG.
INCLUDE STRUCTURE BDCMSGCOLL.
TYPES : END OF T_MSG.
*-- Structure to trap ERROR messages
TYPES : BEGIN OF T_ERR_MSG,
MESSAGE(255),
END OF T_ERR_MSG.
*--Internal table to store flat file data
DATA : BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
KTOKD LIKE T077D-KTOKD,
NAME1 LIKE KNA1-NAME1,
SORTL LIKE KNA1-SORTL,
ORT01 LIKE KNA1-ORT01,
PSTLZ LIKE KNA1-PSTLZ,
LAND1 LIKE KNA1-LAND1,
SPRAS LIKE KNA1-SPRAS,
LZONE LIKE KNA1-LZONE,
END OF IT_KNA1.
*--Internal table to store bank details
DATA : BEGIN OF IT_BANK OCCURS 0,
BANKS LIKE KNBK-BANKS,
BANKL LIKE KNBK-BANKL,
BANKN LIKE KNBK-BANKN,
END OF IT_BANK.
*-- Internal table to hold BDC data
DATA: IT_BDCDATA TYPE STANDARD TABLE OF T_BDCTABLE WITH HEADER LINE,
*-- Internal Table to store ALL messages
IT_MSG TYPE STANDARD TABLE OF T_MSG WITH HEADER LINE,
*-- Internal Table to store error messages
IT_ERR_MSG TYPE STANDARD TABLE OF T_ERR_MSG WITH HEADER LINE.
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FLNAME(15) OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R_LIST RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 5(20) TEXT-003.
PARAMETERS : R_SESS RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 30(20) TEXT-004.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
Event:Initialization *
INITIALIZATION.
AT Selection Screen. *
AT SELECTION-SCREEN.
Event: Start-of-Selection *
START-OF-SELECTION.
V_FNAME = P_FLNAME.
PERFORM GET_DATA.
PERFORM GET_BANKDATA.
PERFORM GENERATE_DATASET.
Event: End-of-Selection *
END-OF-SELECTION.
IF FG_DATA_EXIST = ' '.
MESSAGE I010 WITH TEXT-009.
EXIT.
ENDIF.
PERFORM GENERATE_BDCDATA.
PERFORM DISPLAY_ERR_RECS.
Event: top-of-page
TOP-OF-PAGE.
FORM DEFINITIONS *
*& Form get_data
Subroutine to get the data from mard
--> p1 text
<-- p2 text
FORM GET_DATA.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = 'C:\XD01.TXT'
FILETYPE = 'DAT'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = IT_KNA1
EXCEPTIONS
CONVERSION_ERROR = 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.
ENDIF.
IF IT_KNA1[] IS INITIAL.
FG_DATA_EXIST = ' '.
ENDIF.
ENDFORM. " get_data
*& Form GENERATE_DATASET
text
--> p1 text
<-- p2 text
FORM GENERATE_DATASET.
MESSAGE I010 WITH 'OPENING FILE IN APPLICATION SERVER'.
**--Creating a data set in application server
OPEN DATASET V_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
**---Transfering data from internal table to dataset
MESSAGE I010 WITH 'TRANSFERING DATA FROM INETERAL TABLE TO THE FILE'.
LOOP AT IT_KNA1.
TRANSFER IT_KNA1 TO V_FNAME.
ENDLOOP.
**--Closing the dataset
MESSAGE I010 WITH 'CLOSING THE FILE'.
CLOSE DATASET V_FNAME.
ENDFORM. " GENERATE_DATASET
*& Form BDC_DYNPRO
text
-->P_0467 text
-->P_0468 text
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.
*& Form BDC_FIELD
text
-->P_0472 text
-->P_0473 text
FORM BDC_FIELD USING FNAM FVAL.
IF NOT FVAL IS INITIAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDIF.
ENDFORM.
*& Form GENERATE_BDCDATA
text
--> p1 text
<-- p2 text
FORM GENERATE_BDCDATA.
REFRESH IT_KNA1.
Opening dataset for reading
OPEN DATASET V_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
Reading the file from application server
DO.
CLEAR: IT_KNA1,IT_BDCDATA.
REFRESH IT_BDCDATA.
READ DATASET V_FNAME INTO IT_KNA1.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
Populate BDC Data for Initial Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0100',
BDC_FIELD USING 'BDC_CURSOR' 'RF02D-KUNNR',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'RF02D-KUNNR' IT_KNA1-KUNNR,
BDC_FIELD USING 'RF02D-KTOKD' IT_KNA1-KTOKD.
Populate BDC Data for Second Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0110',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NAME1',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'KNA1-NAME1' IT_KNA1-NAME1,
BDC_FIELD USING 'KNA1-SORTL' IT_KNA1-SORTL,
BDC_FIELD USING 'KNA1-ORT01' IT_KNA1-ORT01,
BDC_FIELD USING 'KNA1-PSTLZ' IT_KNA1-PSTLZ,
BDC_FIELD USING 'KNA1-LAND1' IT_KNA1-LAND1,
BDC_FIELD USING 'KNA1-SPRAS' IT_KNA1-SPRAS.
Populate BDC Data for Third Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0120',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-LZONE',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'KNA1-LZONE' IT_KNA1-LZONE.
Populate BDC Data for Fourth Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0125',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NIELS',
BDC_FIELD USING 'BDC_OKCODE' '/00'.
Populate BDC Data for Table control for bank details.
V_TIDX = '01'.
LOOP AT IT_BANK.
BANKS V_TIDX.
BANKL V_TIDX.
BANKN V_TIDX.
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0130',
BDC_FIELD USING 'BDC_CURSOR' V_BANKN,
BDC_FIELD USING 'BDC_OKCODE' '=ENTR',
BDC_FIELD USING V_BANKS IT_BANK-BANKS,
BDC_FIELD USING V_BANKL IT_BANK-BANKL,
BDC_FIELD USING V_BANKN IT_BANK-BANKN.
V_TIDX = V_TIDX + 1.
ENDLOOP.
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0130',
BDC_FIELD USING 'BDC_CURSOR' V_BANKS,
BDC_FIELD USING 'BDC_OKCODE' '=UPDA'.
CALL TRANSACTION C_XD01 USING IT_BDCDATA
MODE C_MODE
UPDATE C_UPDATE
MESSAGES INTO IT_MSG.
IF SY-SUBRC <> 0.
*--In case of error list display
IF R_LIST = C_X.
V_ERRREC = V_ERRREC + 1.
PERFORM FORMAT_MESSAGE.
IT_ERR_MSG-MESSAGE = V_MSG.
APPEND IT_ERR_MSG.
CLEAR : V_MSG,IT_ERR_MSG.
ENDIF.
*--In case of session log
IF R_SESS = C_X.
*-- In case of transaction fails.
IF FG_SESSION_OPEN = ' '.
FG_SESSION_OPEN = C_X.
PERFORM BDC_OPEN_GROUP.
ENDIF. " IF FG_SESSION_OPEN = ' '.
*-- Insert BDC Data..
PERFORM BDC_INSERT_DATA.
ENDIF. " IF R_SESS = C_X.
ENDIF. " IF SY-SUBRC <> 0.
ENDIF. " IF SY-SUBRC <> 0.
ENDDO.
Closing the dataset
CLOSE DATASET V_FNAME.
*-- Close the session if opened
IF FG_SESSION_OPEN = C_X.
PERFORM BDC_CLOSE_GROUP.
CALL TRANSACTION 'SM35'.
ENDIF.
ENDFORM. " GENERATE_BDCDATA
*& Form BDC_OPEN_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = C_SESS
HOLDDATE = FILLER8
KEEP = C_X
USER = SY-UNAME
RECORD = FILLER1
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
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. " BDC_OPEN_GROUP
*& Form BDC_INSERT_DATA
text
--> p1 text
<-- p2 text
FORM BDC_INSERT_DATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = C_XD01
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
TABLES
DYNPROTAB = IT_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 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.
ENDIF.
ENDFORM. " BDC_INSERT_DATA
*& Form BDC_CLOSE_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_CLOSE_GROUP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 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. " BDC_CLOSE_GROUP
*& Form FORMAT_MESSAGE
text
--> p1 text
<-- p2 text
FORM FORMAT_MESSAGE.
CLEAR V_LINES.
DESCRIBE TABLE IT_MSG LINES V_LINES.
READ TABLE IT_MSG INDEX V_LINES.
CLEAR V_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MSG-MSGID
LANG = IT_MSG-MSGSPRA
NO = IT_MSG-MSGNR
V1 = IT_MSG-MSGV1
V2 = IT_MSG-MSGV2
V3 = IT_MSG-MSGV3
V4 = IT_MSG-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 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.
ENDFORM. " FORMAT_MESSAGE
*& Form DISPLAY_ERR_RECS
text
--> p1 text
<-- p2 text
FORM DISPLAY_ERR_RECS.
LOOP AT IT_ERR_MSG.
WRITE: / IT_ERR_MSG-MESSAGE.
ENDLOOP.
ENDFORM. " DISPLAY_ERR_RECS
*& Form GET_BANKDATA
text
--> p1 text
<-- p2 text
FORM GET_BANKDATA.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = '1000'.
IT_BANK-BANKN = 'S.B A/C'.
APPEND IT_BANK.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = 'CITY'.
IT_BANK-BANKN = 'CURR. A/C'.
APPEND IT_BANK.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = 'H001'.
IT_BANK-BANKN = 'S.B A/C'.
APPEND IT_BANK.
reward if help. -
hi gurus,
i want notes for creating materials and to create purchase order using bdc and to upload some datas using that recording from datas in note pad or any external file with screen shots. if any body sent to it ll be very useful to me...
thanks in advance
arunHi,
check the codes for mm01 and me21n.
mm01
report ZBHMAT no standard page heading line-size 255.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE RMMG1-MATNR,
MBRSH LIKE RMMG1-MBRSH,
MTART LIKE RMMG1-MTART,
KZSEL LIKE MSICHTAUSW-KZSEL,
WERKS LIKE RMMG1-WERKS,
VKORG LIKE RMMG1-VKORG,
VTWEG LIKE RMMG1-VTWEG,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
SKTOF LIKE MVKE-SKTOF,
TAXKM LIKE MG03STEUER-TAXKM,
GEWEI LIKE MARA-GEWEI,
MTVFP LIKE MARC-MTVFP,
TRAGR LIKE MARA-TRAGR,
LADGR LIKE MARC-LADGR,
END OF ITAB.
DATA BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:/BHARAT/MAT.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'MATERIAL'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'RMMG1-MATNR'
ITAB-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
ITAB-MBRSH.
perform bdc_field using 'RMMG1-MTART'
ITAB-MTART.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-KZSEL(04)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
ITAB-KZSEL.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'RMMG1-WERKS'
ITAB-WERKS.
perform bdc_field using 'RMMG1-VKORG'
ITAB-VKORG.
perform bdc_field using 'RMMG1-VTWEG'
ITAB-VTWEG.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'MG03STEUER-TAXKM(01)'
ITAB-TAXKM.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4200'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARA-GEWEI'
ITAB-GEWEI.
perform bdc_field using 'MARC-MTVFP'
ITAB-MTVFP.
perform bdc_field using 'MARA-TRAGR'
ITAB-TRAGR.
perform bdc_field using 'MARC-LADGR'
ITAB-LADGR.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = BDCTAB.
REFRESH BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
me21n
report ZBH_PURORDER no standard page heading line-size 255.
PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.
DATA FILENAME TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = P_FILE.
START-OF-SELECTION.
FILENAME = P_FILE.
DATA:BEGIN OF XTAB OCCURS 0,
TYP,
DES(255) TYPE C,
END OF XTAB.
DATA:BEGIN OF ITAB OCCURS 0,
SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,
EKORG LIKE MEPO1222-EKORG,
EKGRP LIKE MEPO1222-EKGRP,
BUKRS LIKE MEPO1222-BUKRS,
END OF ITAB.
DATA:BEGIN OF JTAB OCCURS 0,
N(4) TYPE C,
EMATN LIKE MEPO1211-EMATN,
MENGE(13) TYPE C,
NETPR(13) TYPE C,
NAME1 LIKE MEPO1211-NAME1,
END OF JTAB.
DATA:BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:DELIMITER VALUE '*'.
DATA A TYPE I.
DATA M(4) TYPE N.
DATA L_FNAM(30) TYPE C.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = XTAB.
LOOP AT XTAB.
IF XTAB-TYP = 'H'.
SPLIT XTAB-DES AT DELIMITER INTO ITAB-SUPERFIELD ITAB-EKORG ITAB-EKGRP
ITAB-BUKRS.
JTAB-N = JTAB-N + 1.
APPEND ITAB.
ELSEIF XTAB-TYP = 'I'.
SPLIT XTAB-DES AT DELIMITER INTO JTAB-EMATN JTAB-MENGE JTAB-NETPR
JTAB-NAME1.
APPEND JTAB.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'PORDER'
KEEP = 'X'
USER = SY-UNAME.
LOOP AT ITAB.
A = SY-TABIX.
REFRESH BDCTAB.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_CURSOR'
'MEPO_TOPLINE-SUPERFIELD'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4000BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1222-EKORG'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4001BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
M = 1.
LOOP AT JTAB.
IF JTAB-N = A.
WRITE:/ JTAB.
CONCATENATE 'MEPO1211-EMATN(' M ')' INTO L_FNAM.
perform bdc_field using 'BDC_CURSOR'
L_FNAM.
perform bdc_field using L_FNAM
JTAB-EMATN.
CONCATENATE 'MEPO1211-MENGE(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-MENGE.
CONCATENATE 'MEPO1211-NETPR(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NETPR.
CONCATENATE 'MEPO1211-NAME1(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NAME1.
M = M + 1.
ENDIF.
ENDLOOP.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1319-MATKL'.
perform bdc_field using 'MEPO1319-SPINF'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=MESAVE'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ME21N'
TABLES
DYNPROTAB = BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
FLAT FILE:
H1171611000001*1000
ICPU116000*1000
ILEY BOARD1010000*1000
IMOUSE66000*1000
H1171711000001*1000
ICPU580000*1000
H1171701000001*1000
IMOUSE33000*1000
ILEY BOARD1010000*1000
rgds,
bharat. -
Hi guys please give me sample code for call transaction that handles error
hi guys, please give me sample code for call transaction that handles error,
please send me the sample code in which there should be all decleration part and everything, based on the sample code i will develop my code.
please do help me as it is urgent.
thanks and regards.
prasadnn.Hi Prasad,
Check this code.
Source Code for BDC using Call Transaction
*Code used to create BDC
*& Report ZBDC_EXAMPLE *
*& Example BDC program, which updates net price of item 00010 of a *
*& particular Purchase order(EBELN). *
REPORT ZBDC_EXAMPLE NO STANDARD PAGE HEADING
LINE-SIZE 132.
Data declaration
TABLES: ekko, ekpo.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
waers TYPE ekko-waers,
netpr TYPE ekpo-netpr,
err_msg(73) TYPE c,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_error TYPE t_ekko,
it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_success TYPE t_ekko.
DATA: w_textout LIKE t100-text.
DATA: gd_update TYPE i,
gd_lines TYPE i.
*Used to store BDC data
DATA: BEGIN OF bdc_tab OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.
*Used to stores error information from CALL TRANSACTION Function Module
DATA: BEGIN OF messtab OCCURS 0.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF messtab.
*Screen declaration
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
TITLE text-001. "Purchase order Num
SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME
TITLE text-002. "New NETPR value
PARAMETERS: p_newpr(14) TYPE c obligatory. "LIKE ekpo-netpr.
SELECTION-SCREEN END OF BLOCK block2.
*START-OF-SELECTION
START-OF-SELECTION.
Retrieve data from Purchase order table(EKKO)
SELECT ekkoebeln ekkowaers ekpo~netpr
INTO TABLE it_ekko
FROM ekko AS ekko INNER JOIN ekpo AS ekpo
ON ekpoebeln EQ ekkoebeln
WHERE ekko~ebeln IN so_ebeln AND
ekpo~ebelp EQ '10'.
*END-OF-SELECTION
END-OF-SELECTION.
Check data has been retrieved ready for processing
DESCRIBE TABLE it_ekko LINES gd_lines.
IF gd_lines LE 0.
Display message if no data has been retrieved
MESSAGE i003(zp) WITH 'No Records Found'(001).
LEAVE TO SCREEN 0.
ELSE.
Update Customer master data (instalment text)
LOOP AT it_ekko INTO wa_ekko.
PERFORM bdc_update.
ENDLOOP.
Display message confirming number of records updated
IF gd_update GT 1.
MESSAGE i003(zp) WITH gd_update 'Records updated'(002).
ELSE.
MESSAGE i003(zp) WITH gd_update 'Record updated'(003).
ENDIF.
Display Success Report
Check Success table
DESCRIBE TABLE it_success LINES gd_lines.
IF gd_lines GT 0.
Display result report column headings
PERFORM display_column_headings.
Display result report
PERFORM display_report.
ENDIF.
Display Error Report
Check errors table
DESCRIBE TABLE it_error LINES gd_lines.
If errors exist then display errors report
IF gd_lines GT 0.
Display errors report
PERFORM display_error_headings.
PERFORM display_error_report.
ENDIF.
ENDIF.
*& Form DISPLAY_COLUMN_HEADINGS
Display column headings
FORM display_column_headings.
WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
SKIP.
WRITE:2 'The following records updated successfully:'(013).
WRITE:/ sy-uline(42).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(004), sy-vline,
(11) 'Old Netpr'(005), sy-vline,
(11) 'New Netpr'(006), sy-vline.
WRITE:/ sy-uline(42).
ENDFORM. " DISPLAY_COLUMN_HEADINGS
*& Form BDC_UPDATE
Populate BDC table and call transaction ME22
FORM bdc_update.
PERFORM dynpro USING:
'X' 'SAPMM06E' '0105',
' ' 'BDC_CURSOR' 'RM06E-BSTNR',
' ' 'RM06E-BSTNR' wa_ekko-ebeln,
' ' 'BDC_OKCODE' '/00', "OK code
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'EKPO-NETPR(01)',
' ' 'EKPO-NETPR(01)' p_newpr,
' ' 'BDC_OKCODE' '=BU'. "OK code
Call transaction to update customer instalment text
CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'
MESSAGES INTO messtab.
Check if update was succesful
IF sy-subrc EQ 0.
ADD 1 TO gd_update.
APPEND wa_ekko TO it_success.
ELSE.
Retrieve error messages displayed during BDC update
LOOP AT messtab WHERE msgtyp = 'E'.
Builds actual message based on info returned from Call transaction
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = w_textout.
ENDLOOP.
Build error table ready for output
wa_error = wa_ekko.
wa_error-err_msg = w_textout.
APPEND wa_error TO it_error.
CLEAR: wa_error.
ENDIF.
Clear bdc date table
CLEAR: bdc_tab.
REFRESH: bdc_tab.
ENDFORM. " BDC_UPDATE
FORM DYNPRO *
stores values to bdc table *
--> DYNBEGIN *
--> NAME *
--> VALUE *
FORM dynpro USING dynbegin name value.
IF dynbegin = 'X'.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-program,
value TO bdc_tab-dynpro,
'X' TO bdc_tab-dynbegin.
APPEND bdc_tab.
ELSE.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-fnam,
value TO bdc_tab-fval.
APPEND bdc_tab.
ENDIF.
ENDFORM. " DYNPRO
*& Form DISPLAY_REPORT
Display Report
FORM display_report.
FORMAT COLOR COL_NORMAL.
Loop at data table
LOOP AT it_success INTO wa_success.
WRITE:/ sy-vline,
(10) wa_success-ebeln, sy-vline,
(11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,
(11) p_newpr, sy-vline.
CLEAR: wa_success.
ENDLOOP.
WRITE:/ sy-uline(42).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM. " DISPLAY_REPORT
*& Form DISPLAY_ERROR_REPORT
Display error report data
FORM display_error_report.
LOOP AT it_error INTO wa_error.
WRITE:/ sy-vline,
(10) wa_error-ebeln, sy-vline,
(11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,
(73) wa_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
ENDFORM. " DISPLAY_ERROR_REPORT
*& Form DISPLAY_ERROR_HEADINGS
Display error report headings
FORM display_error_headings.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(009), sy-vline,
(11) 'Netpr'(010), sy-vline,
(73) 'Error Message'(012), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM. " DISPLAY_ERROR_HEADINGS
Hope this resolves your query.
Reward all the helpful answers.
Regards -
BDC Recording for cm07 Transaction
Hi Everyone,
I'm doing BDC recording for CM07 transaction. In Recording, i need to give a print command by specifying the spool title.
For this, after opening the print window, i need to click the 'properties' button, and then select the spool title and input the value.
But I'm unable to do the recording of this print dialog box. The recording ends as soon as I give the print command.
Can anyone please tell me the solution to it.
Thanks and Regards
Rishika bawaHi,
See via transaction SHDB:
SAPLCORU_S 0100 X
BDC_OKCODE BU
AFRUD-RUECK 0000000000
AFRUD-AUFNR 100051152
AFRUD-VORNR 0010
AFRUD-LMNGA 100,000
AFRUD-MEINH PC
AFRUD-XMNGA 2,000
AFRUD-ISM01 200
AFRUD-ILE01 PC
The table for confirmations is AFRU.
Best regards,
Leandro Mengue -
Hi,
Can anybody please tell the BDC CODE FOR A PUSH BUTTON.
THANKS IN ADVANCEwhich program? which pushbutton?
-
OTL: Timecard Audit Template require reason code for all transaction.
We are currently using OTL with CLA template with interface time entry from external system.
When monthly time entry interfaced into OTL each employee have to review and update their time and submit to manager, but when process to audit template they has been forced to update reason code for all transactions.
We suppose to update the reason code only for the modified transactions. Please help me.
Nonny.nondhasid,
If you are not modifying those records which are asking for a reason field to be filled, then it should be coming from the Late setup. Check the CLA setup.
--Shiv -
Blocking a company code for all transactions.
A compnay code is having two plants assigned. No open documents in that company code.
How to block the company code for any transactions including purchase document creation?
However all the past data to be available for viewing and reference.
Thanks in advance.
NarasimharaoDear Narasimharao ,
You can remove authorization from user profile to use this company code.
And when someone try to save any documents , error message will be send.
hope this could help you.
best regards,
Carlos Moçatto -
BDC code for MB01 Application(Multiple Line Items)
Hi,
Can anybody please send me the BDC CODE for MB01 Application(for Multiple Line items).
Very urgent.
Thanks And Regards,
AjayInstead of BDC you can use following BAPI.
see the following ex:
BAPI TO Upload Inventory Data
GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
02 - MB31 - Goods Receipts for Prod Order
03 - MB1A - Goods Issue
04 - MB1B - Transfer Posting
05 - MB1C - Enter Other Goods Receipt
06 - MB11
Domain: KZBEW - Movement Indicator
Goods movement w/o reference
B - Goods movement for purchase order
F - Goods movement for production order
L - Goods movement for delivery note
K - Goods movement for kanban requirement (WM - internal only)
O - Subsequent adjustment of "material-provided" consumption
W - Subsequent adjustment of proportion/product unit material
LOOP AT I_TAB.
count = sy-tabix.
SELECT SINGLE * FROM ZMM_GI_WIP
WHERE GI_NO = I_TAB-DOCNO AND
GI_DATE = I_TAB-DOCDT.
IF SY-SUBRC = 0.
I_TAB-FLAG = 'C'.
modify i_tab index count.
CONCATENATE 'ERROR GI : ' I_TAB-DOCNO
' WAS ALREADY UPLOADED' INTO I_MSG1.
APPEND I_MSG1.
CLEAR I_TAB-FLAG.
CONTINUE.
ELSE.
CONCATENATE I_TAB-DOCDT+4(2)
I_TAB-DOCDT+6(2)
I_TAB-DOCDT+2(2)
I_TAB-DOCDT+0(2)
INTO G_DATE.
gmhead-pstng_date = G_DATE.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
"01 - MB01 - Goods Receipts for Purchase Order
gmcode-gm_code = '03'.
refresh itab.
clear itab.
SORT I_MAIN BY SOL_DOCNO.
LOOP AT I_MAIN WHERE DOCNO = I_TAB-DOCNO.
IF I_MAIN-GI_TXN_TYPE = 'MGI'.
itab-move_type = '291'.
ENDIF.
itab-mvt_ind = ' '.
itab-plant = I_MAIN-WERKS.
itab-material = I_MAIN-MATNR.
itab-entry_qnt = I_MAIN-ERFMG.
itab-stge_loc = I_MAIN-LGOBE.
itab-ENTRY_UOM = I_MAIN-ERFME.
IF I_MAIN-WERKS = 'MR'.
itab-TR_PART_BA = '11'.
ELSEIF I_MAIN-WERKS = 'MR'.
itab-TR_PART_BA = '12'.
ENDIF.
append itab.
ENDLOOP.
if not itab[] is initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
move errmsg-message to i_msg1.
append i_msg1.
endloop.
if errflag is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
endif.
endif.
ENDIF.
wait up to 20 seconds.
ENDLOOP. -
Hi friends,
I have to upload data using mm01 transaction.
My program has to select respective views according to material type.
Can anybody help me.
Thanks and regards,
Pavani.Hi,
You will save lot of time & energy if you opt to use BAPI_MATERIAL_SAVEDATA. Have a look @the sample code. Please note Do not allocate any points as this code doesn't belong to me, however I have tested it & it works fine.
TABLES bapi_MVKEx.
* FLAGS
DATA: F_STOP. " Flag used to stop processing
* DATA DECLARATIONS
DATA : V_EMPTY TYPE I, " No. of empty records
V_TOTAL TYPE I. " Total no. of records.
* STRUCTURES & INTERNAL TABLES
*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control
"Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_MVKE1 LIKE BAPI_MVKE, "Sales Data
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold excel file data
DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold Matetrial descriptions
DATA: BEGIN OF IT_MAKT OCCURS 100.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- Internal to hold the records in the text file
DATA : BEGIN OF IT_DATA OCCURS 100,
WERKS(4), " Plant
MTART(4), " Material type
MATNR(18), " Material number
MATKL(9) , " Material group
MBRSH(1), " Industry sector
MEINS(3), " Base unit of measure
GEWEI(3), " Weight Unit
SPART(2), " Division
EKGRP(3), " Purchasing group
VPRSV(1), " Price control indicator
STPRS(12), " Standard price
PEINH(3), " Price unit
SPRAS(2), " Language key
MAKTX(40), " Material description
MTPOS_MARA(4), "Item Category Group
vkorg(4), "Sales Org
vtweg(2), "Dist channel
Prdha(18), "Prod Hierarchy
ladgr(4), " Loading Group
prctr(10), "Profit Centr
xchpf(1), "Batch Mgmt
kondm(2), "Material Pricing Grp
ktgrm(2), "Account Assignment Grp
mvgr1(4),
mvgr2(4),
mvgr3(4),
versg(1), "Material Statistics Grp
* Added fields not part of the layout
sapmatnr(18),
END OF IT_DATA.
* SELECTION SCREEN. *
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
'H:\DATA\Nova\rbc\zrbc129.xls'.
PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK SCR1.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*--- Validating file
PERFORM VALIDATE_FILE USING P_FILE.
* START-OF-SELECTION
START-OF-SELECTION.
*--- Perform to convert the Excel data into an internal table
PERFORM CONVERT_XLS_ITAB.
IF NOT IT_DATA[] IS INITIAL.
*--- Perform to delete Header lines
PERFORM DELETE_HEADER_EMPTY_RECS.
ENDIF.
* END OF SELECTION.
END-OF-SELECTION.
*--- Perform to upload Material Master data
PERFORM UPLOAD_MATMAS.
* Form : validate_input_file
* Description : To provide F4 help for file if read from PC
FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
exporting
STATIC = 'X'
CHANGING
FILE_NAME = F_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
*MESSAGE S010" 'Error in getting filename'.
ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
* To convert XLS to internal table
FORM CONVERT_XLS_ITAB.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = P_BEGCOL
I_BEGIN_ROW = P_BEGROW
I_END_COL = P_ENDCOL
I_END_ROW = P_ENDROW
TABLES
INTERN = IT_INTERN.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--- Perform to move the data into an internal data
PERFORM MOVE_DATA.
ENDFORM. " CONVERT_XLS_ITAB
*& Form MOVE_DATA
* text
FORM MOVE_DATA.
DATA : LV_INDEX TYPE I.
FIELD-SYMBOLS: <fs> type any.
*--- Sorting the internal table
SORT IT_INTERN BY ROW COL.
CLEAR IT_INTERN.
LOOP AT IT_INTERN.
MOVE IT_INTERN-COL TO LV_INDEX.
*--- Assigning the each record to an internal table row
ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <fs>.
*--- Asigning the field value to a field symbol
<fs> = it_intern-value.
*MOVE IT_INTERN-VALUE TO <fs>.
AT END OF ROW.
APPEND IT_DATA.
CLEAR IT_DATA.
ENDAT.
ENDLOOP.
ENDFORM. " MOVE_DATA
*& Form DELETE_HEADER_EMPTY_RECS
* To delete the Header and empty records
FORM DELETE_HEADER_EMPTY_RECS.
DATA: LV_TABIX LIKE SY-TABIX.
IF NOT P_HEADER IS INITIAL.
LOOP AT IT_DATA.
IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
DELETE IT_DATA FROM 1 TO P_HEADER.
* P_HEADER = 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
CLEAR IT_DATA.
*--- To delete the empty lines from internal table
LOOP AT IT_DATA.
LV_TABIX = SY-TABIX.
IF IT_DATA IS INITIAL.
V_EMPTY = V_EMPTY + 1.
DELETE IT_DATA INDEX LV_TABIX..
ENDIF.
ENDLOOP.
CLEAR IT_DATA.
*--- Total no of recs in file
DESCRIBE TABLE IT_DATA LINES V_TOTAL.
IF V_TOTAL = 0.
*MESSAGE I013" No records in the file
F_STOP = 'X'.
STOP.
ENDIF.
ENDFORM. " DELETE_HEADER_EMPTY_RECS
*& Form UPLOAD_MATMAS
* to upload Material Master data
FORM UPLOAD_MATMAS .
LOOP AT IT_DATA.
* Header
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = it_data-matnr
IMPORTING
OUTPUT = it_data-sapmatnr
EXCEPTIONS
LENGTH_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.
BAPI_HEAD-MATERIAL = IT_DATA-sapMATNR.
BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
BAPI_HEAD-SALES_VIEW = 'X'.
BAPI_HEAD-QUALITY_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
IT_MAKT-LANGU = IT_DATA-SPRAS.
IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
APPEND IT_MAKT.
* Client Data - Basic
BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
BAPI_MARA1-DIVISION = IT_DATA-SPART.
BAPI_MARA1-item_cat = it_data-mtpos_mara.
BAPI_MARA1-PROD_HIER = it_data-prdha.
bapi_marax-item_cat = 'X'.
bapi_marax-prod_hier = 'X'.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-DIVISION = 'X'.
* Plant - Purchasing
BAPI_MARC1-PLANT = IT_DATA-WERKS.
BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
BAPI_MARC1-LOADINGGRP = IT_DATA-LADGR.
BAPI_MARC1-PROFIT_CTR = IT_DATA-prctr.
BAPI_MARC1-BATCH_MGMT = IT_DATA-xchpf.
bapi_marc1-qm_authgrp = 'X'.
bapi_marcx-qm_authgrp = 'X'.
BAPI_MARCX-PLANT = IT_DATA-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
BAPI_MARCX-LOADINGGRP = 'X'.
BAPI_MARCX-PROFIT_CTR = 'X'.
BAPI_MARCX-BATCH_MGMT = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
BAPI_MBEWX-PRICE_UNIT = 'X'.
* Sales Data
BAPI_MVKE1-ITEM_CAT = IT_DATA-MTPOS_MARA.
BAPI_MVKEX-ITEM_CAT = 'X'.
BAPI_MVKE1-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKEX-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKE1-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKEX-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKE1-MAT_PR_GRP = IT_DATA-kondm.
BAPI_MVKEX-MAT_PR_GRP = 'X'.
BAPI_MVKE1-ACCT_ASSGT = IT_DATA-ktgrm.
BAPI_MVKEX-ACCT_ASSGT = 'X'.
BAPI_MVKE1-MATL_GRP_1 = IT_DATA-mvgr1.
BAPI_MVKEX-MATL_GRP_1 = 'X'.
BAPI_MVKE1-MATL_GRP_2 = IT_DATA-mvgr2.
BAPI_MVKEX-MATL_GRP_2 = 'X'.
BAPI_MVKE1-MATL_GRP_3 = IT_DATA-mvgr3.
BAPI_MVKEX-MATL_GRP_3 = 'X'.
BAPI_MVKE1-matl_stats = IT_DATA-versg.
BAPI_MVKEX-matl_stats = 'X'.
*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
PLANTDATA = BAPI_MARC1
PLANTDATAX = BAPI_MARCX
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,it_data-matnr.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created/Changed material' ,it_data-matnr.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
IMPORTING
return = return.
ENDIF.
ENDLOOP.
ENDFORM. " UPLOAD_MATMAS
Regards
Raju Chitale -
Bdc code for transfer of asset plant wise stock transfer (urgent)
hi all,
if anyone has done BDC for this scenario ie.,
bdc for transfer of asset plant wise stock transfer
then plz share its code with me.and if someone has done any modification regarding this scenario then plz let me know that what modification he/she has carried out in this & share the code for the same.
i will be grateful to u for this and promise that i will give points to all ur effort.
Thanks & regards
SanjeevHi Sanjeev,
Do a recording for the transaction using SHDB. Once you are done with the recording save the recording into a zprogram. You have the code.
Regards
Arun -
Dynamic select views for MM01 Transaction
Hii Friends,
I have an issue like i need to dynamically select the views in MM01 transaction from the BDC program
without selecting that views manually.
Using SHDB recording i can select the views before recording and then call those views again
If i want to select the views from the program how do i do it..
If there is any way to do this in call transaction let me know plz
Thanks in advance
kishoreBDC is not good for MM01 , go for bapi
other wise go for LSMW bapi method...
Business Object BUS1001006 Standard material
Method SAVEDATA Create and change materia
Message Type MATMAS_BAPI Create and change materia
Basic Type MATMAS_BAPI02 Create and Change Materia -
BDC Recording for 3 transactions in SD
i need to cancel contracts using these transaction sequentialy i.e VF46 VF11and VF42 using bdc .how to go about it in recording for 3 transactions
regards
shankarHi try this,
Call one BDC after the another, Like if u want to create a sales order and then correspondingly display it as well, u can capture the sales order created afer ur first BDC theu the messages mostly in SYMSGV1 and using this u can do a call txn skip first screne of VA03.
If u are talking about session, get 2 session names and move them to different sessions or if both txn are dependant on each other, move it one after the other thru call txn. It is the same, howmany ever trx u wabnt to post thru BDC.
OR
After your call transaction stmnt, check for sy-subrc = 0 and refresh bdc internal table.
Populate the bdc internal table for the new trxn and then call the trxn using call transaction stmnt. -
BDC Code for Loan to Employees
Dear Friends,
I have to write a BDC where I have to debit the G/L of Empoyee Loan and credit individual employee accounts.
If you have a similar BDC code available with you please share the same with me.
Regards,
Alok.hi
First go to tcode SHDB, there select new recording,give a name for the recording and then give the tcode for which u would want to do recording. Now, enter all the values in the tcode completely and then save it.
Now, come back to shdb,..select ur recording and say create a program tab. Select option from the recording aand then save the program..save the program.
Now, upload the flat file from PC using GUI_upload for txt file and ALSM_EXCEL_TO_INTERNAL_TABLE..
Now, pass the internal table values to the perform statements or subroutines and put them in a loop.
Regards,
Vishwa.
Maybe you are looking for
-
Album view in iTunes 11 unusable because singles showing as "Unknown Album"
I have lots of "singles" in my collection (ie mp3s with nothing in the "album" field) as well as lots of albums. Because of this, the "albums" view in iTunes 11 is virtually unusable, as 80% of the music shows as "Unknown Album" and prevents me from
-
ITunes 7 wont load!!!! HELP?
Right, when I double click the shortcut for iTunes (and the actual exe itself for that matter) a "iTunes has encountered a problem and needs to close. We are sorry for the inconvenience." screen comes up", it's the usual debug/tell microsoft thing wi
-
How can i export pictures in PNG FILE
Using adobe Lr 4.4
-
I am having increasing difficulties making a proper connection to recharge the battery. It seems that the contacts are not working properly. I thought it was some dirt in the little hole but sometimes I need to move the plug to start the charging pro
-
Reduce pdf size for Livescribe files
Does anyone have Livescribe for Mac? I am trying to reduce the pdf size of these files once I convert, and having no luck with ColorSync filters. Any help would be appreciated!