Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

error in bapi

Former Member
0 Likes
1,390

when i updating table MVKE using bapi BAPI_MATERIAL_SAVEDATA, theres a error saying "Enter a validity date". Pls help

6 REPLIES 6
Read only

Former Member
0 Likes
974

Hi,

Please check this code

REPORT Ztests.

*---tables used

tables:bapimathead,

bapi_makt,

bapi_mara,

bapi_marax. *--declaration for internal table data:begin of itab occurs 0,

MATERIAL type BAPIMATHEAD-MATERIAL,

IND_SECTOR(20),

MATL_TYPE type bapimathead-MATL_TYPE,

MATL_GROUP type bapi_mara-MATL_GROUP,

LANGU TYPE BAPI_MAKT-LANGU,

MATL_DESC TYPE BAPI_MAKT-MATL_DESC,

end of itab, it_return like BAPIRET2, IT_BAPI LIKE BAPI_MAKT OCCURS 0 WITH HEADER LINE. *---selection screen

parameters:p_file TYPE IBIPPARMS-PATH obligatory. *---f4 help for the file from PC

at selection-screen on value-request for p_file. perform get_f4help. *--start-of-selection .

start-of-selection. perform upload_file_itab. perform call_bapi. &----


*& Form get_f4help

&----


form get_f4help . CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE . endform. " get_f4help

&----


*& Form upload_file_itab

&----


form upload_file_itab . DATA:V_FILE TYPE STRING.

MOVE P_FILE TO V_FILE. CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = V_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

data_tab = ITAB . endform. " upload_file_itab

&----


*& Form call_bapi

&----


form call_bapi . loop at itab. BAPIMATHEAD-material = itab-MATERIAL.

bapimathead-IND_SECTOR = itab-IND_SECTOR.

BAPIMATHEAD-MATL_TYPE = itab-MATL_TYPE.

BAPIMATHEAD-BASIC_VIEW = 'X'. bapi_mara-MATL_GROUP = itab-MATL_GROUP.

bapi_mara-base_uom = 'KGS'.

bapi_marax-MATL_GROUP = 'X'.

bapi_marax-BASE_UOM = 'X'. IT_BAPI-LANGU = ITAB-LANGU.

IT_BAPI-LANGU_ISO = 'EN'.

IT_BAPI-MATL_DESC = ITAB-MATL_DESC.

APPEND IT_BAPI.

clear it_bapi. CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = BAPIMATHEAD

CLIENTDATA = bapi_mara

CLIENTDATAX = bapi_marax

IMPORTING

RETURN = it_RETURN

TABLES

MATERIALDESCRIPTION = IT_BAPI . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' . *---this is the message type which indicates whether it is failed or succeded

write:/ it_return-TYPE. endloop. endform. " call_bapi

Here is the test file used for creating the materials in the above program:

000000000011111111 T RFRM 001 EN this is test material

000000000011111112 T RFRM 001 EN this is test material

000000000011111113 T RFRM 001 EN this is test material

000000000011111114 T RFRM 001 EN this is test material

000000000011111115 T RFRM 001 EN this is test material

000000000011111116 T RFRM 001 EN this is test material

000000000011111117 T RFRM 001 EN this is test material

Read only

Former Member
0 Likes
974

pls check the date field,may be they are back date,thus giving error.

Read only

Former Member
0 Likes
974

Hi

Pls pass the valid from date value to SALESDATA-VALID_FROM and pass 'X' to SALESDATAX-VALID_FROM

Regards

Madhan D

Read only

Former Member
0 Likes
974

Hi,

Check if the said bapi has a parameter that we can input a validity date. Try entering a date there before running the program.

Hope this helps.

Benedict

Read only

Former Member
0 Likes
974

thanks

Read only

Former Member
0 Likes
974

Hi,

You need to pass the valuation class to the structure VALUATIONDATA-VAL_CLASS in the BAPI 'BAPI_MATERIAL_SAVEDATE'.

Or

refer to the link below :

Thank You.

Regards,

Dhanalaskhmi L