SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_REQUIREMENTS_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Apr 12, 2008 10:03 am    Post subject: BAPI_REQUIREMENTS_CREATE Reply with quote

BAPI_REQUIREMENTS_CREATE - Planned Independent Requirements: Create Planned Independent Reqmts

Code:
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.
write : '上载数据出错,请检查文本文件是否存在或格式错误!'.
* 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) '创建成功'.
 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.

write : '批输入结束!请检查LOG文件!'.
endform.
*----------create end------------
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.