BDC-CALL

report ZDSN
       
no standard page heading line-size 255.

*----------------------------------------------------------------------*
*   data definition
*----------------------------------------------------------------------*
*       Batchinputdata of single transaction
DATA:   bdcdata LIKE bdcdata    OCCURS WITH HEADER LINE.
*       messages of call transaction
DATA:   messtab LIKE bdcmsgcoll OCCURS WITH HEADER LINE.
*       error session opened (' ' or 'X')
DATA:   e_group_opened.
*       message texts
TABLESt100.


typesbegin of ty_mat,
       matnr
(18type c,
       mbrsh
(1type c,
       mtart
(4type c,
       maktx
(40type c,
       meins
(3type c,
       
end of ty_mat.

  
datait_mat type table of ty_mat,
        wa_mat 
type ty_mat.

  
parametersp_file type  IBIPPARMS-PATH.

at selection-screen on value-request for p_file.

  
CALL FUNCTION 'F4_FILENAME'
   
EXPORTING
     PROGRAM_NAME        
SYST-CPROG
     DYNPRO_NUMBER       
SYST-DYNNR

   
IMPORTING
     FILE_NAME           
=  p_file
            
.

data:lv_FILE TYPE  STRING.

   lv_FILE 
p_file.

   
CALL FUNCTION 'GUI_UPLOAD'
     
EXPORTING
       filename                     
lv_FILE
      FILETYPE                      
'ASC'
      HAS_FIELD_SEPARATOR           
'x'

     
tables
       data_tab                      
it_mat
    
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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   
ENDIF.



*include bdcrecx1.

start-of-selection.

loop at it_mat into wa_mat.

perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field       using 'BDC_CURSOR'
                              
'RMMG1-MTART'.
perform bdc_field       using 'BDC_OKCODE'
                              
'=AUSW'.
perform bdc_field       using 'RMMG1-MATNR'
                              wa_mat
-matnr.
perform bdc_field       using 'RMMG1-MBRSH'
                              wa_mat
-mbrsh.
perform bdc_field       using 'RMMG1-MTART'
                              wa_mat
-mtart.
perform bdc_dynpro      using 'SAPLMGMM' '0070'.
perform bdc_field       using 'BDC_CURSOR'
                              
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              
'=ENTR'.
perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                              
'X'.
perform bdc_dynpro      using 'SAPLMGMM' '4004'.
perform bdc_field       using 'BDC_OKCODE'
                              
'=BU'.
perform bdc_field       using 'MAKT-MAKTX'
                              wa_mat
-maktx.
perform bdc_field       using 'BDC_CURSOR'
                              
'MARA-MEINS'.
perform bdc_field       using 'MARA-MEINS'
                              wa_mat
-meins.
perform bdc_transaction using 'MM01'.

endloop.

*----------------------------------------------------------------------*
*        Start new transaction according to parameters                 *
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
  
DATAl_mstring(480).
  
DATAl_subrc LIKE sy-subrc.

    
REFRESH messtab.
    
CALL TRANSACTION tcode USING bdcdata
          
MODE   'a'
          
UPDATE 's'
          messages 
INTO messtab.

      
WRITE'CALL_TRANSACTION',
      tcode
,
      
'returncode:'(i05),
      l_subrc
,
      
'RECORD:',
      sy
-INDEX.
      
LOOP AT messtab.
            
message id messtab-msgid
                    
type messtab-msgtyp
                    
number messtab-msgnr
                    
into l_mstring
    
WITH  MESSTAB-MSGV1
    MESSTAB
-MSGV2
    MESSTAB
-MSGV3
    MESSTAB
-MSGV4.


          
WRITE/ messtab-msgtypl_mstring(250).

      
ENDLOOP.

  
REFRESH bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING PROGRAM DYNPRO.
  
CLEAR bdcdata.
  bdcdata
-PROGRAM  PROGRAM.
  bdcdata
-DYNPRO   DYNPRO.
  bdcdata
-dynbegin 'X'.
  
APPEND bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  
IF fval <> space.
    
CLEAR bdcdata.
    bdcdata
-fnam fnam.
    bdcdata
-fval fval.
    
APPEND bdcdata.
  
ENDIF.
ENDFORM.

Comments

Popular posts from this blog

FOR ALL ENTRIES (FAE) -4 TABLES USING ALV_GRID_DISPLAY

RADIO-BUTTONS IN BASIC REPORT

MODULE POOL -TABLE CONTROL_1: