How to use BAPI BAPI_MATERIAL_SAVEDATA
Hi,
I'm tryng to use the bapi BAPI_MATERIAL_SAVEDATA to create and change material.
Thanks to his forum, I created a simple program to understand how the BAPI works.
My problem is that the BAPI doesn't give me error message but doesn't create the material.
Any suggest?
REPORT Z_BAPI_MAT.
STRUCTURE DECLARATIONS *
TABLES: BAPIMATHEAD, "Headerdata
BAPI_MARA, "Clientdata
BAPI_MARAX, "Clientdatax
BAPI_MAKT, "Material description
BAPIRET2. "Return messages
DATA:V_FILE TYPE STRING.
DATA:
BEGIN OF LSMW_MATERIAL_MASTER,
MATNR(018) TYPE C, "Material number
MTART(004) TYPE C, "Material type
MBRSH(001) TYPE C, "Industry sector
WERKS(004) TYPE C, "Plant
MAKTX(040) TYPE C, "Material description
MEINS(003) TYPE C, "Base unit of measure
MATKL(009) TYPE C, "Material group
END OF LSMW_MATERIAL_MASTER.
INTERNAL TABLE DECLARATIONS *
*to store the input data
DATA:
BEGIN OF it_matmaster OCCURS 0.
INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
DATA:
END OF it_matmaster.
**for material description
DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
INCLUDE STRUCTURE BAPI_MAKT .
DATA:END OF IT_MATERIALDESC.
*to return messages
DATA:BEGIN OF IT_RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF IT_RETURN.
DATA:BEGIN OF BAPI_MATRETURN2 OCCURS 0.
INCLUDE STRUCTURE BAPI_MATRETURN2.
DATA:END OF BAPI_MATRETURN2.
DATA:BEGIN OF BAPIRET3 OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF BAPIRET3.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY default 'c:\test.txt'.
SELECTION-SCREEN END OF BLOCK B1 .
TO UPLOAD THE DATA *
START-OF-SELECTION.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_file
FILETYPE = 'DAT'
TABLES
data_tab = IT_MATMASTER
DATA POPULATIONS *
LOOP AT IT_MATMASTER.
BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
BAPIMATHEAD-BASIC_VIEW = 'X'.
BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
IT_MATERIALDESC-LANGU = 'EN'.
IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
append IT_materialdesc.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = BAPIMATHEAD
CLIENTDATA = BAPI_MARA
CLIENTDATAX = BAPI_MARAx
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
RETURN = IT_RETURN
TABLES
MATERIALDESCRIPTION = IT_MATERIALDESC
RETURNMESSAGES = BAPI_MATRETURN2
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRET3
Output message
WRITE:/ IT_MATMASTER-matnr,'->',
IT_RETURN-TYPE,
20 IT_RETURN-ID,
42 IT_RETURN-NUMBER,
45 IT_RETURN-MESSAGE.
loop at BAPI_MATRETURN2.
write: / BAPI_MATRETURN2.
endloop.
loop at BAPIRET3.
write: / BAPIRET3.
endloop.
ENDLOOP.
Hi,
are you giving all the Parameters Properly, try to Debug it and check it. it may be because of commit problem. try to Check that, in Debug definitely you can Able to Create the Material.
or else you can use this Direct Input Program to create the Material.
REPORT Z_MATERIAL_CREATION .
**STANDARD STRUCTURES FOR MATERIAL CREATION
TABLES:
BGR00,
BMM00,
BMMH1.
**DATA Declarations
DATA:C_ZTEST(60) TYPE C ,
C_X TYPE C ,
C_N TYPE C ,
V_FILE TYPE STRING.
**FILED SYMBOL TO PASS THE NODATA '/'
FIELD-SYMBOLS: <F> .
***STRUCTURE TO HOLD THE FLAT FILE DATA
DATA:
BEGIN OF LSMW_MATERIAL_MASTER,
MATNR(018) TYPE C, "Material number
MTART(004) TYPE C, "Material type
MBRSH(001) TYPE C, "Industry sector
WERKS(004) TYPE C, "Plant
MAKTX(040) TYPE C, "Material description
DISMM(002) TYPE C, "Extra Field Added In the Program as it is required
MEINS(003) TYPE C, "Base unit of measure
MATKL(009) TYPE C, "Material group
SPART(002) TYPE C, "Division
LABOR(003) TYPE C, "Lab/office
PRDHA(018) TYPE C, "Product hierarchy
MSTAE(002) TYPE C, "X-plant matl status
MTPOS_MARA(004) TYPE C, "Gen item cat group
BRGEW(017) TYPE C, "Gross weight
GEWEI(003) TYPE C, "Weight unit
NTGEW(017) TYPE C, "Net weight
GROES(032) TYPE C, "Size/Dimensions
MAGRV(004) TYPE C, "Matl grp pack matls
BISMT(018) TYPE C, "Old material number
WRKST(048) TYPE C, "Basic material
PROFL(003) TYPE C, "DG indicator profile
KZUMW(001) TYPE C, "Environmentally rlvt
BSTME(003) TYPE C, "Order unit
VABME(001) TYPE C,
EKGRP(003) TYPE C, "Purchasing group
XCHPF(001) TYPE C, "Batch management
EKWSL(004) TYPE C, "Purchasing key value
WEBAZ(003) TYPE C, "GR processing time
MFRPN(040) TYPE C, "Manufacturer part number
MFRNR(010) TYPE C, "Manufacturer number
VPRSV(001) TYPE C, "Price control indicator
STPRS(015) TYPE C, "Standard price
BWPRH(014) TYPE C, "Commercial price1
END OF LSMW_MATERIAL_MASTER.
**INTERNAL TABLE TO HOLD THE MATERIAL MASTER DATA
DATA:
BEGIN OF MATERIAL_MASTER OCCURS 0.
INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
DATA:
END OF MATERIAL_MASTER.
* SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1 .
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
* START-OF_SELECTION
START-OF-SELECTION.
V_FILE = P_FILE.
**UPLOADING THE DATA TO THE FLAT FILE
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = MATERIAL_MASTER
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.
DELETE MATERIAL_MASTER INDEX 1.
ENDIF.
**CONSTANTS
C_ZTEST = 'Ztest.lsmw.conv'(001).
C_X = 'X'(003).
C_N ='N'(004).
IF NOT MATERIAL_MASTER IS INITIAL.
***POPULATING BGR00 STRUCTURE
PERFORM CONVERT_0000. " BGR00
***POPULATING BMM00 STRUCTURE
PERFORM POPULATE_DATA CHANGING BMM00.
***POPULATING BMMH1 STRUCTURE
PERFORM POPULATE_DATA CHANGING BMMH1.
**LOOPING THE DATA AND UPDATING THE STRUCTURES
LOOP AT MATERIAL_MASTER.
OPEN DATASET C_ZTEST FOR APPENDING IN TEXT MODE ENCODING
DEFAULT.
PERFORM CONVERT_0002. " BMM00
PERFORM CONVERT_0003. " BMMH1
CLOSE DATASET C_ZTEST.
ENDLOOP. "END OF MATERIAL_MASTER LOOP
ENDIF.
*& END-OF_SELECTION
END-OF-SELECTION.
SUBMIT RMDATIND WITH %%%_R_P = C_X
WITH %%%_PHY = C_ZTEST
WITH SPERR = C_N.
*& Form convert_0000
* text
FORM CONVERT_0000. " BGR00
OPEN DATASET C_ZTEST FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
MOVE: '0' TO BGR00-STYPE,
'ZTEST' TO BGR00-GROUP,
SY-MANDT TO BGR00-MANDT,
SY-UNAME TO BGR00-USNAM,
'X' TO BGR00-XKEEP,
'/' TO BGR00-NODATA.
TRANSFER BGR00 TO C_ZTEST.
CLOSE DATASET C_ZTEST.
ENDFORM. "convert_0001
*& Form convert_0002
* text
FORM CONVERT_0002. " BMM00
* --- BMM00-STYPE
BMM00-STYPE = '1'.
* --- BMM00-TCODE
BMM00-TCODE = 'MM01'.
* --- BMM00-MATNR
IF NOT MATERIAL_MASTER-MATNR IS INITIAL.
BMM00-MATNR = MATERIAL_MASTER-MATNR.
ELSE.
BMM00-MATNR = '/'.
ENDIF.
* --- BMM00-MBRSH
IF NOT MATERIAL_MASTER-MBRSH IS INITIAL.
BMM00-MBRSH = MATERIAL_MASTER-MBRSH.
ELSE.
BMM00-MBRSH = '/'.
ENDIF.
* --- BMM00-MTART
IF NOT MATERIAL_MASTER-MTART IS INITIAL.
BMM00-MTART = MATERIAL_MASTER-MTART.
ELSE.
BMM00-MTART = '/'.
ENDIF.
* --- BMM00-WERKS
IF NOT MATERIAL_MASTER-WERKS IS INITIAL.
BMM00-WERKS = MATERIAL_MASTER-WERKS.
ELSE.
BMM00-WERKS = '/'.
ENDIF.
BMM00-XEIB1 = 'X'. " BMM00-xeib1 = '/'.
BMM00-XEIE1 = 'X'. " BMM00-xeie1 = '/'.
BMM00-XEIK1 = 'X'. " BMM00-xeik1 = '/'.
TRANSFER BMM00 TO C_ZTEST.
ENDFORM. "convert_0002
*& Form convert_0003
* text
FORM CONVERT_0003. " BMMH1
* --- BMMH1-STYPE
BMMH1-STYPE = '2'.
* --- BMMH1-MEINS
IF NOT MATERIAL_MASTER-MEINS IS INITIAL.
BMMH1-MEINS = MATERIAL_MASTER-MEINS.
ELSE.
BMMH1-MEINS = '/'.
ENDIF.
* --- BMMH1-MAKTX
IF NOT MATERIAL_MASTER-MAKTX IS INITIAL.
BMMH1-MAKTX = MATERIAL_MASTER-MAKTX.
ELSE.
BMMH1-MAKTX = '/'.
ENDIF.
* --- BMMH1-MATKL
IF NOT MATERIAL_MASTER-MATKL IS INITIAL.
BMMH1-MATKL = MATERIAL_MASTER-MATKL.
ELSE.
BMMH1-MATKL = '/'.
ENDIF.
* --- BMMH1-BISMT
IF NOT MATERIAL_MASTER-BISMT IS INITIAL.
BMMH1-BISMT = MATERIAL_MASTER-BISMT.
ELSE.
BMMH1-BISMT = '/'.
ENDIF.
* --- BMMH1-LABOR
IF NOT MATERIAL_MASTER-LABOR IS INITIAL.
BMMH1-LABOR = MATERIAL_MASTER-LABOR.
ELSE.
BMMH1-LABOR = '/'.
ENDIF.
* --- BMMH1-WRKST
IF NOT MATERIAL_MASTER-WRKST IS INITIAL.
BMMH1-WRKST = MATERIAL_MASTER-WRKST.
ELSE.
BMMH1-WRKST = '/'.
ENDIF.
* --- BMMH1-BRGEW
IF NOT MATERIAL_MASTER-BRGEW IS INITIAL.
BMMH1-BRGEW = MATERIAL_MASTER-BRGEW.
ELSE.
BMMH1-BRGEW = '/'.
ENDIF.
* --- BMMH1-NTGEW
IF NOT MATERIAL_MASTER-NTGEW IS INITIAL.
BMMH1-NTGEW = MATERIAL_MASTER-NTGEW.
ELSE.
BMMH1-NTGEW = '/'.
ENDIF.
* --- BMMH1-GEWEI
IF NOT MATERIAL_MASTER-GEWEI IS INITIAL.
BMMH1-GEWEI = MATERIAL_MASTER-GEWEI.
ELSE.
BMMH1-GEWEI = '/'.
ENDIF.
* --- BMMH1-GROES
IF NOT MATERIAL_MASTER-GROES IS INITIAL.
BMMH1-GROES = MATERIAL_MASTER-GROES.
ELSE.
BMMH1-GROES = '/'.
ENDIF.
* --- BMMH1-SPART
IF NOT MATERIAL_MASTER-SPART IS INITIAL.
BMMH1-SPART = MATERIAL_MASTER-SPART.
ELSE.
BMMH1-SPART = '/'.
ENDIF.
* --- BMMH1-BSTME
IF NOT MATERIAL_MASTER-BSTME IS INITIAL.
BMMH1-BSTME = MATERIAL_MASTER-BSTME.
ELSE.
BMMH1-BSTME = '/'.
ENDIF.
* --- BMMH1-EKWSL
IF NOT MATERIAL_MASTER-EKWSL IS INITIAL.
BMMH1-EKWSL = MATERIAL_MASTER-EKWSL.
ELSE.
BMMH1-EKWSL = '/'.
ENDIF.
* --- BMMH1-EKGRP
IF NOT MATERIAL_MASTER-EKGRP IS INITIAL.
BMMH1-EKGRP = MATERIAL_MASTER-EKGRP.
ELSE.
BMMH1-EKGRP = '/'.
ENDIF.
* --- BMMH1-XCHPF
IF NOT MATERIAL_MASTER-XCHPF IS INITIAL.
BMMH1-XCHPF = MATERIAL_MASTER-XCHPF.
ELSE.
BMMH1-XCHPF = '/'.
ENDIF.
* --- BMMH1-WEBAZ
IF NOT MATERIAL_MASTER-WEBAZ IS INITIAL.
BMMH1-WEBAZ = MATERIAL_MASTER-WEBAZ.
ELSE.
BMMH1-WEBAZ = '/'.
ENDIF.
IF NOT MATERIAL_MASTER-DISMM IS INITIAL.
BMMH1-DISMM = MATERIAL_MASTER-DISMM.
ELSE.
BMMH1-DISMM = '/'.
ENDIF.
* --- BMMH1-VPRSV
IF NOT MATERIAL_MASTER-VPRSV IS INITIAL.
BMMH1-VPRSV = MATERIAL_MASTER-VPRSV.
ELSE.
BMMH1-VPRSV = '/'.
ENDIF.
BMMH1-VERPR = '/'.
* --- BMMH1-STPRS
IF NOT MATERIAL_MASTER-STPRS IS INITIAL.
BMMH1-STPRS = MATERIAL_MASTER-STPRS.
ELSE.
BMMH1-STPRS = '/'.
ENDIF.
* --- BMMH1-BWPRH
IF NOT MATERIAL_MASTER-BWPRH IS INITIAL.
BMMH1-BWPRH = MATERIAL_MASTER-BWPRH.
ELSE.
BMMH1-BWPRH = '/'.
ENDIF.
* --- BMMH1-PRDHA
IF NOT MATERIAL_MASTER-PRDHA IS INITIAL.
BMMH1-PRDHA = MATERIAL_MASTER-PRDHA.
ELSE.
BMMH1-PRDHA = '/'.
ENDIF.
* --- BMMH1-VABME
IF NOT MATERIAL_MASTER-VABME IS INITIAL.
BMMH1-VABME = MATERIAL_MASTER-VABME.
ELSE.
BMMH1-VABME = '/'.
ENDIF.
* --- BMMH1-MAGRV
IF NOT MATERIAL_MASTER-MAGRV IS INITIAL.
BMMH1-MAGRV = MATERIAL_MASTER-MAGRV.
ELSE.
BMMH1-MAGRV = '/'.
ENDIF.
* --- BMMH1-KZUMW
IF NOT MATERIAL_MASTER-KZUMW IS INITIAL.
BMMH1-KZUMW = MATERIAL_MASTER-KZUMW.
ELSE.
BMMH1-KZUMW = '/'.
ENDIF.
* --- BMMH1-MFRNR
IF NOT MATERIAL_MASTER-MFRNR IS INITIAL.
BMMH1-MFRNR = MATERIAL_MASTER-MFRNR.
ELSE.
BMMH1-MFRNR = '/'.
ENDIF.
* --- BMMH1-MFRPN
IF NOT MATERIAL_MASTER-MFRPN IS INITIAL.
BMMH1-MFRPN = MATERIAL_MASTER-MFRPN.
ELSE.
BMMH1-MFRPN = '/'.
ENDIF.
* BMMH1-MPROF = '/'.
* --- BMMH1-MSTAE
IF NOT MATERIAL_MASTER-MSTAE IS INITIAL.
BMMH1-MSTAE = MATERIAL_MASTER-MSTAE.
ELSE.
BMMH1-MSTAE = '/'.
ENDIF.
* --- BMMH1-PROFL
IF NOT MATERIAL_MASTER-PROFL IS INITIAL.
BMMH1-PROFL = MATERIAL_MASTER-PROFL.
ELSE.
BMMH1-PROFL = '/'.
ENDIF.
* --- BMMH1-MTPOS_MARA
IF NOT MATERIAL_MASTER-MTPOS_MARA IS INITIAL.
BMMH1-MTPOS_MARA = MATERIAL_MASTER-MTPOS_MARA.
ELSE.
BMMH1-MTPOS_MARA = '/'.
ENDIF.
TRANSFER BMMH1 TO C_ZTEST.
ENDFORM. "convert_0003
*& Form POPULATE_DATA
* text
* <--P_BLF text
FORM POPULATE_DATA CHANGING P_BLF.
DATA: L_NUM TYPE I.
DO.
L_NUM = L_NUM + 1.
ASSIGN COMPONENT L_NUM OF STRUCTURE P_BLF TO <F>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
MOVE BGR00-NODATA TO <F>.
ENDDO.
ENDFORM. " POPULATE_DATA
Regards
vijay
Similar Messages
-
How to use bapi response in XI
HI ALL,
Can any one suggest me, how to use bapi response in XI as a sender.
I m using bapi BAPI_BCA_BANKSTATEMENT_EXECUTE , I am executing this bapi manually ,but want to use this BAPI RESPONSE in XI as a sender and map it with receiver.
can i have any idea about how to do it, or can i have the idoc which is used by this bapi BAPI_BCA_BANKSTATEMENT_EXECUTE.
THANX
HONEYHi Honey,
Have a look at these
-Configuring the Sender RFC Adapter - step by step
/people/michal.krawczyk2/blog/2005/03/29/configuring-the-sender-rfc-adapter--step-by-step
-Troubleshooting - RFC and SOAP scenarios
/people/shabarish.vijayakumar/blog/2008/01/08/troubleshooting--rfc-and-soap-scenarios-updated-on-20042009
-sender RFC (forum thread)
Is it possible to use the RFC sender adapter for asynchronous calls?
Regards,
Sreenivas -
How to use BAPI with Decision Dialogue
Hi Gurus
would you please let me know how to use BAPI with decision dialogue in guided procedure .
I have a BAPI checking logon credentials for the user . how to use this BAPI for making decisions that is if the logon is correct then perform one process else go to logon screen again .
Thanks in advance
Regards NamitaHi Namita,
1. Follow the steps mentioned in section <a href="http://help.sap.com/saphelp_crm50/helpdata/en/33/198141f906040de10000000a1550b0/frameset.htm">Exposing an RFC-Enabled Function Module as a Callable Object</a> to use the BAPI as a Callable Object.
2. Follow the steps mentioned in tutorial # 93 and 93a in the CAF Tutorial Center for the decision part.
Hope these helps.
Nilay -
How to use BAPI function module for maintaing product type to material
Hi,
Can you pls suggest me how to use BAPI Fuction module CCAP_REV_LEVEL_MAINTAIN
for maintaining the product type for the material using change number.
Pts will be rewarded.
Best Regards,
PadhyHi,
Can you pls suggest me how to use BAPI Fuction module CCAP_REV_LEVEL_MAINTAIN
for maintaining the product type for the material using change number.
Pts will be rewarded.
Best Regards,
Padhy -
Upload the Plant by using BAPI " BAPI_MATERIAL_SAVEDATA"
Hi experts ,
I have a requirement where i need to update the plant for the material.
i tried to use BAPI " BAPI_MATERIAL_SAVEDATA"
Can any one please help me out what are the import and export parameters we need to pass for updating the Plant for that particluar material.
If any one have any sample code please send .
Thanks in advance.
Anupama . PHi
When creating material master data, you must transfer the material number, the material type, and the industry sector to the method. You must also enter a material description and its language.
When changing material master data, you need enter only the material number.
In the header data, you must select at least one view for which data is to be created. Depending on the view selected, you must maintain other required parameters. If you do not enter values for all of the required parameters, the method is ended with an error message.
For what fields to be filled up, please go to SE37, Enter the BAPI, click on display
Click on Import tab page , clcik on the Associated type of Parmeters
HEADDATA
CLIENTDATA
PLANTDATA
& any other data which you want to upload ,
Thanks & Regards
Kishore -
Hi
How to use bapis
BAPI_COMPANYCODE_GET_PERIOD
BAPI_CCODE_GET_FIRSTDAY_PERIOD'
BAPI_GL_ACC_GETPERIODBALANCES'BAPI_COMPANYCODE_GET_PERIOD:
To retrieve the fiscal year variant for a given date u can use the following function module
Retrieve fiscal year and period
The below code shows how to use function modules BAPI_COMPANYCODE_GET_PERIOD and
DETERMINE_PERIOD to retrieve fiscal year and fiscal period for a specific date.
*: Report: ZFISCALYR :
*: Author: www.SAPdev.co.uk :
*: Date : 2004 :
*: Description: Demonstrates how to return the corresponding fiscal :
*: year and posting period for a company code and posting :
*: date or posting date and fiscal year variant. :
REPORT zfiscalyr NO STANDARD PAGE HEADING.
TABLES: ekko.
PARAMETERS: p_bukrs TYPE ekko-bukrs,
p_bedat TYPE ekko-bedat.
DATA: gd_fiscalyr TYPE bapi0002_4-fiscal_year,
gd_fiscalp TYPE bapi0002_4-fiscal_period.
DATA: gd_fiscalyr2 TYPE T009B-BDATJ,
gd_fiscalp2 TYPE bapi0002_4-fiscal_period.
DATA: gd_periv TYPE t009-periv.
*START-OF-SELECTION.
START-OF-SELECTION.
get fiscal year and period - (requires date and company code)
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
companycodeid = p_bukrs
posting_date = p_bedat
IMPORTING
fiscal_year = gd_fiscalyr
fiscal_period = gd_fiscalp.
Alternative fiscal year function module
- (requires date and fiscal year variant code from T009 table)
gets first entry in fiscal year variant table (will need to choose
correct one from table rather than just using first entry)
SELECT SINGLE periv
FROM t009
INTO gd_periv.
get fiscal year and period
CALL FUNCTION 'DETERMINE_PERIOD'
EXPORTING
date = p_bedat
PERIOD_IN = '000'
version = gd_periv
IMPORTING
period = gd_fiscalp2
year = gd_fiscalyr2
EXCEPTIONS
period_in_not_valid = 1
period_not_assigned = 2
version_undefined = 3
OTHERS = 4.************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
WRITE:/ 'From function module: BAPI_COMPANYCODE_GET_PERIOD',
/ 'Fiscal year is:', gd_fiscalyr,
/ 'Fiscal period is:', gd_fiscalp.
SKIP.
WRITE:/ 'From function module: DETERMINE_PERIOD',
/ 'Fiscal year is:', gd_fiscalyr2,
/ 'Fiscal period is:', gd_fiscalp2.
how to get the fiscal year
BAPI_CCODE_GET_FIRSTDAY_PERIOD:
CALL FUNCTION 'BAPI_CCODE_GET_FIRSTDAY_PERIOD'
EXPORTING
companycodeid = v_bukrs
fiscal_period = marv-lfmon
fiscal_year = marv-lfgja
IMPORTING
first_day_of_period = v_postdate
return = i_return1.
BAPI
function module which could calculate the previous month's start date.....
BAPI_GL_ACC_GETPERIODBALANCES:
Transactions or BAPI for GL account
Please give me reward point... -
How to use BAPI to add a new version for a claim number in WTY transaction.
How to use BAPI to add a new version for a claim number in WTY transaction.
I am using function module " BAPI_WARRANTYCLAIM_ADD_VERSION ".
It needs to copy all contents of previous version to a new version.
While doing so i am unable to copy fields like valic valoc etc. Any ways by which i can copy this values.
WTY will update PNWTYH , PNWTYV and PVWTY tables.
Thanking you,
Lokesh.Hi Vishnu,
You can do that through EEWB. Please go through SAP Note 484597. You would get the details of using Easy Enhancement Work bench.
Rewards point if you think this info is useful
Regards,
Dipender Singh -
Will you tell me how to use BAPI "L_TO_CREATE_POSTING_CHANGE" ,please?
Is lt06 bapi "L_TO_CREATE_POSTING_CHANGE"?just do a where used list of the FM and see how its used in those programs.
one of the programs where it is used = RLLQ0200
Regards
Raja -
Create material using bapi ' bapi_material_savedata'
Hi Experts,
i was tring to create material using bapi ' bapi_material_savedata' but the material is not updating in the table.
please find the code and suggest me if any modification
data: la_headdata type BAPIMATHEAD,
la_clientdata type BAPI_MARA,
la_CLIENTDATAX type BAPI_MARAX,
la_return type BAPIRET2.
data: i_materialdescription type table of BAPI_MAKT,
wa_materialdescription like line of i_materialdescription.
*la_headdata-MATERIAL = int_matnum-MATERIAL.
*LOOP AT int_matnum.
la_headdata-MATERIAL = int_matnum-MATERIAL.
write : int_matnum-material.
*ENDLOOP.
la_headdata-MATERIAL = '100000518'."int_matnum-MATERIAL.
la_headdata-IND_SECTOR = p_indsr.
la_headdata-MATL_TYPE = p_matype.
la_clientdata-BASE_UOM = 'FT3'.
la_clientdata-pur_valkey = ' '.
la_CLIENTDATAX-BASE_UOM = 'X'.
la_clientdata-MATL_GROUP = '01'.
la_CLIENTDATAX-MATL_GROUP = 'X'.
wa_materialdescription = 'TEST'.
append wa_materialdescription to i_materialdescription.
clear: wa_materialdescription.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = la_headdata
CLIENTDATA = la_clientdata
CLIENTDATAX = la_CLIENTDATAX
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
RETURN = la_return
TABLES
MATERIALDESCRIPTION = i_materialdescription
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
Please Help me
Regards,
NareshHi all,
Now it is asking me for the other fields,
E ,
The field MARA-XCHPF/BAPI_MARA-BATCH_MGMT is defined as a required field; it does not contain an entry
i have passed this val as
la_clientdata-batch_mgmt = 'X'.
even though i am getting the same error.
can you help me to solve the issue.
Tthanks
Naresh
Edited by: naresh.k.dasari on Jan 4, 2011 10:36 AM -
Hello ! pls give some ti[ps how to use bapi's for data uploading?
hello !
pls give some ti[ps how to use bapi's for data uploading?
regards,
ArjunHi,
See the below report extract:
where it_data is having uploaded data.
LOOP AT<b> it_data</b> INTO wa_data.
line_count = sy-tabix.
"Date Validation
CONCATENATE wa_data-uplft_date4(4) wa_data-uplft_date2(2) wa_data-uplft_date+0(2)
INTO wa_data-uplft_date.
"READ TABLE it_ekko INTO wa_ekko WITH KEY lifnr = wa_data-vendor.
LOOP AT it_ekko_temp INTO wa_ekko_temp WHERE lifnr = wa_data-vendor.
IF wa_ekko_temp-kdatb <= wa_data-uplft_date AND wa_ekko_temp-kdate >= wa_data-uplft_date.
MOVE-CORRESPONDING wa_ekko_temp TO wa_ekko.
APPEND wa_ekko TO it_ekko.
ENDIF.
ENDLOOP.
"IF sy-subrc = 0 AND wa_ekko-kdatb <= wa_data-uplft_date AND wa_ekko-kdate >= wa_data-uplft_date.
LOOP AT it_ekko INTO wa_ekko.
wa_data_header-pstng_date = wa_data-uplft_date.
wa_data_header-doc_date = sy-datum.
wa_data_header-bill_of_lading = wa_data-bill_of_lad.
wa_data_header-ref_doc_no = wa_data-del_no.
CONCATENATE wa_data-header_text1 '-'
wa_data-header_text2 '-'
wa_data-header_text3 '-'
wa_data-header_text4
into wa_data_header-HEADER_TXT.
IF wa_data-indicator = 'Y'.
wa_data_item-material = '000000000000200568'.
ELSE.
wa_data_item-material = '000000000000200566'.
ENDIF.
LOOP AT it_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln AND matnr = wa_data_item-material.
"Collect Item Level Data
wa_data_item-plant = '1000'.
wa_data_item-stge_loc = '1001'.
wa_data_item-move_type = '101'.
wa_data_item-vendor = wa_data-vendor.
wa_data-qnty = wa_data-qnty / 1000.
wa_data_item-entry_qnt = wa_data-qnty.
wa_data_item-po_pr_qnt = wa_data-qnty.
wa_data_item-entry_uom = 'KL'.
wa_data_item-entry_uom_iso = 'KL'.
wa_data_item-orderpr_un = 'KL'.
wa_data_item-orderpr_un_iso = 'KL'.
wa_data_item-no_more_gr = 'X'.
wa_data_item-po_number = wa_ekpo-ebeln.
wa_data_item-po_item = wa_ekpo-ebelp.
wa_data_item-unload_pt = wa_data-unload_pt.
wa_data_item-mvt_ind = 'B'.
APPEND wa_data_item TO it_data_item.
CLEAR wa_data_item.
ENDLOOP.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = wa_data_header
goodsmvt_code = goodsmvt_code
testrun = 'X'
TABLES
goodsmvt_item = it_data_item
return = return.
READ TABLE return INTO wa_return WITH KEY type = 'S'.
IF sy-subrc <> 0.
DESCRIBE TABLE return LINES sy-tfill.
IF sy-tfill = 0.
CALL FUNCTION <b>'BAPI_GOODSMVT_CREATE'</b>
EXPORTING
goodsmvt_header = wa_data_header
goodsmvt_code = goodsmvt_code
testrun = ' '
TABLES
goodsmvt_item = it_data_item
return = return.
CALL FUNCTION <b>'BAPI_TRANSACTION_COMMIT'</b>
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
ENDIF.
ENDIF.
LOOP AT return INTO wa_return.
WRITE: 'Messsage TYPE ', wa_return-type,
/,'ID ', wa_return-id,
/, 'Number ', wa_return-number,
/, 'Message ', wa_return-message,
/, 'Long Text ', wa_return-message_v1,
wa_return-message_v2,
wa_return-message_v3,
wa_return-message_v4,
/, 'Failed at line', line_count.
ENDLOOP.
CLEAR: wa_ekko, wa_ekpo, wa_data, it_data_item[], wa_data_header.
ENDLOOP.
Reward if useful! -
HOW TO USE BAPI BAPI_BILLINGDOC_CREATEMULTIPLE
HI ALL:
I want to create billing num. in t-code 'VF01'. It is just to input a delivery num.
then press zhe 'save' button.
How to use the bapi BAPI_BILLINGDOC_CREATEMULTIPLE, I mean which
variable should be given. Is there any examples.
THANKS FIRST.Hi,
Following is the documentation provided by SAP in the BAPI transaction:
Functionality
This method can be used to create billing documents.
As input parameters, you are expected to enter information on the items to be processed in the table BILLING_DATA_IN. This data is processed and produces a batch of billing documents. You also have the option of transferring information for entry in the input structure CREATOR_DATA_IN. If this information is already determined, this is transferred into each billing document header. You can also enter optional conditions for the individual items to be processed in the input table CONDITION_DATA_IN, as well as means of payment information in the table CCARD_DATA_IN.
This method can be used in the simulation run (TESTRUN = 'X') and also in the update run including the update (TESTRUN = ' '). Both execution variants deliver errors that may have occurred back to the output table RETURN. Information on successful processing is sent back in the output table SUCCESS. This output table delivers the document numbers of the billing documents created in particular.
Notes
Required entries :
BILLING_DATA_IN-SALESORG
BILLING_DATA_IN-DISTR_CHAN
BILLING_DATA_IN-DIVISION
BILLING_DATA_IN-DOC_TYPE
BILLING_DATA_IN-ORDBILLTYP
BILLING_DATA_IN-SOLD_TO
BILLING_DATA_IN-ITEM_CATEG
BILLING_DATA_IN-REQ_QTY
BILLING_DATA_IN-SALES_UNIT
BILLING_DATA_IN-CURRENCY
If a material is billed for which a material master needs to be
determined (BILLING_DATA_IN-NO_MATMAST = ' '), you must make the
following entries :
BILLING_DATA_IN-PLANT
BILLING_DATA_IN-MATERIAL
If, on the other hand, a material is billed for which no material
master is to be determined (BILLING_DATA_IN_NO_MATMAST = 'X'), you
must make the following entries :
BILLING_DATA_IN-COUNTRY
BILLING_DATA_IN-MATERIAL
BILLING_DATA_IN-TAXCL_1MAT
COMMIT control :
In the update run (TESTRUN = ' ') the update is carried out by COMMIT
WORK as part of the method available.
I guess using this, you will be able to populate the required things to create the billing documents.
Thanks
Vijay -
How to use BAPI get out system language as Chinese?
hi, expert,
i use BAPI get R3 sytem data,but BAPI get data as English,i want get R3 system Chinese data.i set language property value ZH in Model porpery,but BAPI always get english data.
how to solve this problem?
thanksHi Jun,
has you read the following wiki entries:
<a href="https://wiki.sdn.sap.com/wiki/display/VC/WrongLanguage">https://wiki.sdn.sap.com/wiki/display/VC/WrongLanguage</a>
<a href="https://wiki.sdn.sap.com/wiki/display/VC/LanguageMapping">https://wiki.sdn.sap.com/wiki/display/VC/LanguageMapping</a>
Best Regards,
Marcel -
Hi
i have some data in the Legacy file and i have to update in SAP. For that I have to use BAPI, which is ME_DIRECT_INPUT_SOURCE_LIST in the program not in LSMW.
so i have to use
Function ME_INITIALIZE_SOURCE_LIST to initialize the structures and tables
Function ME_DIRECT_INPUT_SOURCE_LIST to enter the data (see data mapping below)
Function ME_POST_SOURCE_LIST_NEW to save the source list.
But i don't know how to use this in the program.
Please help me to solve this problem.Please check this FM - IDOC_INPUT_SRCLST, atleast you will one rough idea about mentioned FM's
-
How to use BAPI to receive goods instead of MB01(move type 101)
I'd like to use BAPI_GOODSMVT_CREATE to receive goods,
(from OEM factory ),
but it can't deduct Bill Of Material AUTO,like packing materials when receive goods,
or is there any BAPI to deduct packing materials?
how?
thanks,experts!
Edited by: MF Z on Dec 1, 2008 6:18 AMI want a BAPI which can deduct BOM(like carton,envelope ) automatically ,
Is there any way to use BAPI to receive goods?
thanks for all reply! -
How to use BAPI Program for change workcenter in co02?
Hi Abapers.
Anybody please tell me how to change the workcenter in CO02 using BAPI Programe.
Please give me sample of this.
I will give urs reward of points.
Thanks
Regards,
S.Muthu.Hi,
Use the Function module CR_WORKCENTER_UPDATE
for workcenter change.
It is an update function module so you have to call it in update mode with a COMMIT statement to trigger it.
CALL FUNCTION CR_WORKCENTER_UPDATE IN UPDATE TASK
exporting...
imporing..
COMMIT WORK.
Note: only after the commit statement the function module will be called in update mode.
Regards,
Raj.
Maybe you are looking for
-
Self Assigned IP Addresses amber lights and no internet HELP!
Ok bear with me as I try to explain my prediciment! I have an imac G5 with a Airport Extreme card properly connected and currently at full signal! The problem I'm having is that when i click safari (or IE) it doesn't load up any pages and a littke bo
-
Macbook Air and iPad iMessage not working
After getting a new iPhone, iMessage no longer works on my iPad and Macbook Air. Advice on how to fix? Thanks!
-
I've noticed a charge on my credit card for $8.49 each month. I looked at my Apple iTunes purchases and don't see it in my purchase history. How do I find out what this charge is for?
-
Fail in converted models migration log
Hi, I have the following Failed in migration log: Failed To Convert Constraint actual time <= current time > NA.NA.actual time <= cWQEBaV_SYSDTRG.actual time <= current time:unexpected AST node: EXEC_PARAM_LIST: Line -1 Column -1 10-JUL-08-17:27:
-
I want to average a row of numbers, but some of the cells are empty. I want the empty cells to be considered null - not included in the averaging calculation. Is there a way to do this? I am using Numbers '08.