Thursday, December 3, 2009

Item Availability check in the Sales Order (VA02)

This is the BDC Program, which Performs the Item Availability check in the Sales Order (VA02). This works as of SAP r/3  4.7 ee Version.

 

  DATA: l_mode(1VALUE 'N'.
  
REFRESH
: it_bdcdata[], it_mesg,it_mesg[].
  
PERFORM bdc_record USING'X' 'SAPMV45A'    '0102'
,
                            
' ' 'BDC_CURSOR'  'VBAK-VBELN'
,
                            
' ' 'BDC_OKCODE'  '/00'
,
                            
' ' 'VBAK-VBELN'
  vbeln,

                            
'X' 'SAPMV45A'    '4001'
,
                            
' ' 'BDC_OKCODE'  '=POPO'
,

                            
'X' 'SAPMV45A'    '0251'
,
                            
' ' 'BDC_CURSOR'  'RV45A-POSNR'
,
                            
' ' 'BDC_OKCODE'  '=POSI'
,
                            
' ' 'RV45A-POSNR'
  posnr,

                            
'X' 'SAPMV45A'    '4001'
,
                            
' ' 'BDC_OKCODE'  '=PORE'
,
                            
' ' 'RV45A-VBAP_SELKZ(01)'  'X'
,

                            
'X' 'SAPMV45A'    '4001'
,
                            
' ' 'BDC_OKCODE'  '=SICH'
.

  
CALL TRANSACTION 'VA02'

             
USING it_bdcdata
              
MODE
 l_mode
              
UPDATE 'S'

     MESSAGES 
INTO it_mesg.

  
READ TABLE it_mesg WITH KEY msgtyp = 'S'
.
  
IF sy-subrc NE 0
.
    
READ TABLE it_mesg WITH KEY msgtyp = 'E'
.
  
ENDIF
.
  
DATA:  l_msg(255
).
  
CALL FUNCTION 'FORMAT_MESSAGE'

    
EXPORTING
      
id        = it_mesg-msgid
      lang      = 
'EN'

      
no        = it_mesg-msgnr
      v1        = it_mesg-msgv1
      v2        = it_mesg-msgv2
      v3        = it_mesg-msgv3
      v4        = it_mesg-msgv4
    
IMPORTING

      msg       = l_msg
    
EXCEPTIONS
      not_found = 
1
      
OTHERS    = 2.
  
IF NOT l_msg IS INITIAL
.
    it_out-rem = l_msg.
  
ENDIF
.



No comments: