技术开发 频道

ABAP实例:通过BDC倒入员工照片的参考代码

【IT168 技术文章】

REPORT ZHR_BDC_UPLOADPIC
         NO STANDARD PAGE HEADING LINE
-SIZE 255.
    INCLUDE BDCRECX1.

    
*I N T E R N A L T A B L E S
    DATA : BEGIN OF IT_DATA OCCURS
0,
            RP50G
-PERNR(8), " LIKE RP50G-PERNR,
            RLGRAP-FILENAME(128),
         END OF IT_DATA.
    
*S T A R T - O F - S E L E C T I O N
    START
-OF-SELECTION.

    PERFORM OPEN_GROUP.
    CALL FUNCTION
'UPLOAD'
         EXPORTING
              FILENAME                
= 'C:\PICTURE.TXT'
              FILETYPE                
= 'DAT'
         TABLES
              DATA_TAB                
= IT_DATA
         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 NE 0.
      WRITE :
/ 'Unable to upload data'.
      STOP.
    ENDIF.
    LOOP AT IT_DATA.
      PERFORM BDC_DYNPRO      USING
'OANEWCON' '0100'.
      PERFORM BDC_FIELD       USING
'BDC_CURSOR'
                                    
'TOAOM-AR_OBJECT'.
      PERFORM BDC_FIELD       USING
'BDC_OKCODE'
                                    
'=NEW'.
      PERFORM BDC_FIELD       USING
'TOAOM-SAP_OBJECT'
                                    
'PREL'.
      PERFORM BDC_FIELD       USING
'TOAOM-AR_OBJECT'
                                    
'HRICOLFOTO'.
      PERFORM BDC_DYNPRO      USING
'SAPLSJ01' '0200'.
      PERFORM BDC_FIELD       USING
'BDC_CURSOR'
                                    
'FIELD_VALUES-INPUT(02)'.
      PERFORM BDC_FIELD       USING
'BDC_OKCODE'
                                    
'=OK'.
      PERFORM BDC_FIELD       USING
'FIELD_VALUES-INPUT(01)'
                                IT_DATA
-RP50G-PERNR.       "'10002'.
      PERFORM BDC_FIELD       USING 'FIELD_VALUES-INPUT(02)'
                                    
'0002'.
      PERFORM BDC_DYNPRO      USING
'SAPLOPTM' '0105'.
      PERFORM BDC_FIELD       USING
'BDC_CURSOR'
                                    
'SAPB-SAPPOOLINF'.
      PERFORM BDC_FIELD       USING
'BDC_OKCODE'
                                    
'=OKAY'.
      PERFORM BDC_FIELD       USING
'SAPB-SAPPOOLINF'
                                IT_DATA
-RLGRAP-FILENAME.      "JPG'.
      PERFORM BDC_TRANSACTION USING 'OAOH'.
      clear IT_DATA
-RLGRAP-FILENAME.
    ENDLOOP.
    PERFORM CLOSE_GROUP.
0
相关文章