Application Development 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: 

BAPI "BAPI_REQUIREMENTS_CREATE"

Former Member
0 Kudos

Hi All

I want to forcast data from excel file in trasaction MD61.

There is no exit I have found to do that. In past threads I've found

BAPI_REQUIREMENTS_CREATE this BAPI.

but how to use it can anybody tell me...

thnx in advance

3 REPLIES 3

Former Member
0 Kudos

Hi,

Please go thru this link,u can get the sample code:

http://blog.csdn.net/CompassButton/archive/2007/05/08/1600621.aspx.

Hope it helps.

Regards,

Rahul

0 Kudos

Hey its coming is some Chinese language I guess....

Former Member
0 Kudos

REPORT ZTY_MM_BAPI_REQUIREMENTS .

*bapi data

data: req_item like BAPISITEMR.

data: req_data like BAPISSHDIN occurs 0 with header line.

data: RETURN LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE.

data: matertemp like BAPISITEMR-MATERIAL.

data: begin of wa_itab,

index type i,

matnr like BAPISITEMR-MATERIAL,

REQ_QTY like BAPISSHDIN-REQ_QTY,

end of wa_itab.

data: itab like wa_itab occurs 0 with header line.

data: matemp like BAPISITEMR-MATERIAL.

data: begin of log occurs 0,

index type i,

MESSAGE like return-message,

end of log.

SELECTION-SCREEN: BEGIN OF BLOCK FRAME01

WITH FRAME TITLE Text-001.

parameters: p_number like pbpt-pbdnr obligatory.

parameters: p_today like sy-datum obligatory.

parameters: TXTFILE like rlgrap-filename default

'c:\material.txt' obligatory.

parameters: logfile like rlgrap-filename default

'c:\log.txt' obligatory.

SELECTION-SCREEN: END OF BLOCK FRAME01.

SELECTION-SCREEN: BEGIN OF BLOCK FRAME02

WITH FRAME TITLE TEXT-002.

SELECTION-SCREEN COMMENT /5(40) TEXT-003.

SELECTION-SCREEN: END OF BLOCK FRAME02.

START-OF-SELECTION.

PERFORM FRM_GET_DATA.

PERFORM FRM_CREATE_requ.

end-of-selection.

*--


upload data--


FORM FRM_GET_DATA.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = TXTFILE

FILETYPE = 'DAT'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10

.

IF SY-SUBRC 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

exit.

ENDIF.

ENDFORM.

*loop at itab.

  • itab-index = sy-index.

  • itab-plan = '8000'.

  • itab-requ = 'vse'.

  • itab-v = 'X'.

  • itab-req_number = p_number.

  • modify itab.

*endloop.

*--


upload data end----

*--


create requirements-

FORM FRM_CREATE_requ.

loop at itab.

concatenate '00000000000' itab-matnr into matertemp.

req_item-material = matertemp.

req_item-plant = '8000'.

req_item-REQU_TYPE = 'VSE'.

req_item-VERSION = '00'.

req_item-VERS_ACTIV = 'X'.

req_item-req_number = p_number.

req_data-DATE_TYPE = 3.

req_data-req_date = p_today.

req_data-REQ_QTY = itab-REQ_QTY.

append req_data.

CALL FUNCTION 'BAPI_REQUIREMENTS_CREATE'

EXPORTING

REQUIREMENTS_ITEM = req_item

  • REQUIREMENT_PARAM =

IMPORTING

MATERIAL = matemp

  • PLANT =

  • REQUIREMENTSTYPE =

  • VERSION =

  • REQMTSPLANNUMBER =

TABLES

REQUIREMENTS_SCHEDULE_IN = REQ_data

  • REQUIREMENTS_CHAR_IN =

RETURN = RETURN.

IF NOT matemp IS INITIAL.

WRITE:/(10) matemp COLOR 4,

(50) 'mat'.

else.

log-index = itab-index.

log-message = return-MESSAGE.

append log.

ENDIF.

clear matemp.

REFRESH req_data.

clear matertemp.

clear req_item.

endloop.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = LOGFILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = LOG

EXCEPTIONS

INVALID_FILESIZE = 1

INVALID_TABLE_WIDTH = 2

INVALID_TYPE = 3

NO_BATCH = 4

UNKNOWN_ERROR = 5

GUI_REFUSE_FILETRANSFER = 6

CUSTOMER_ERROR = 7

OTHERS = 8

.

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.