Monday, December 7, 2009

Table Logging /Change history of the table entries

Table Logging : SCU3

Check the Table Logging flag in the technical settings of the table(SE11).

 



Delivery Pick Qty Function Module

Use Function Module WB2_GET_PICK_QUANTITY to get the Pick Qty from the Delivery.

Pass the Delivery no and Delivery Item No as shown in the screen.

 



How to Find a BADI/User exit for a Transaction

Run The following Program from se38.
Code:
REPORT ztestdp_badi_find
*-----------------------------------------------------------------------
* Author         : DurgaPrasad                                         *
* Creation Date  : 03 Dec 2009                                         *
* Valid Upto Version SAP r/3 4.7.
* Steps To run this Program:(User Guide);
*.1. Run This prorgam from SE38
* 2. Run your Transaction for which you wanted to find the BADI's
* 3. When your Trsnaction stopped at Break point, check
*    the value of parameter 'EXIT_NAME'.
*    It will show you the BADI for that transaction.
*----------------------------------------------------------------------
* version: ZTESTDP_BADI_FIND v1.0
* For support
*-----------------------------------------------------------------------
* <<< Start of Comment:5005070995  :04.12.2009:

* <<< End   of Comment:5005070995  :04.12.2009:

       NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*       messages of call transaction
DATA:   messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
*       error session opened (' ' or 'X')
DATA:   e_group_opened.
*       message texts
TABLES: t100.
START-
OF-SELECTION.


perform bdc_dynpro      using 'SAPLSEOD' '1000'.
perform bdc_field       using 'BDC_CURSOR'
                              'SEOCLASS-CLSNAME'.
perform bdc_field       using 'BDC_OKCODE'
                              '=CIDI'.
perform bdc_field       using 'SEOCLASS-CLSNAME'
                              'CL_EXITHANDLER'.
perform bdc_dynpro      using 'SAPLSEOD' '2000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=OO_PICKUP'.
perform bdc_field       using 'BDC_CURSOR'
                              'DY_0253-CPDNAME(02)'.
perform bdc_dynpro      using 'SAPLSEO_CLEDITOR' '0200'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ED_SET_BREAK'.
perform bdc_dynpro      using 'SAPLSEO_CLEDITOR' '0200'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ED_SET_BREAK'.
perform bdc_dynpro      using 'SAPLSEO_CLEDITOR' '0200'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ED_SET_BREAK'.
perform bdc_dynpro      using 'SAPLSEO_CLEDITOR' '0200'.
perform bdc_field       using 'BDC_OKCODE'
                              '/EWB_BACK'.
perform bdc_dynpro      using 'SAPLSEOD' '2000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=WB_BACK'.
perform bdc_field       using 'BDC_CURSOR'
                              'DY_0253-CPDNAME(02)'.
perform bdc_dynpro      using 'SAPLSEOD' '1000'.
perform bdc_field       using 'BDC_CURSOR'
                              'SEOCLASS-CLSNAME'.
perform bdc_field       using 'BDC_OKCODE'
                              '=WB_BACK'.
perform bdc_field       using 'SEOCLASS-CLSNAME'
                              'CL_EXITHANDLER'.

  
CALL TRANSACTION 'SE24' USING bdcdata
  
mode 'E'
  MESSAGES INTO  messtab.
if sy-subrc = 0.
  
MESSAGE i016(zz) with 'Success' text-004 text-001.
* text-004 Run your Tcode Now
*text-001 Check parameter 'EXIT_NAME' at the Break Point.
"Check the value of parameter 'EXIT_NAME'.
"  It will show you the BADI for that transaction.
  else.
MESSAGE i016(zz) with 'Error.Run Again'.
    
endif.

*perform close_group.


FORM bdc_dynpro USING program dynpro.
  
CLEAR bdcdata.
  bdcdata-
program  = program.
  bdcdata-
dynpro   = dynpro.
  bdcdata-dynbegin = 
'X'.
  
APPEND bdcdata.
ENDFORM.                    "BDC_DYNPRO

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.

  
CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  
APPEND bdcdata.
ENDFORM.                    "BDC_FIELD
 
Run the transaction for which you wanted to find a BADI. When your Transaction stopped at Break point, check    the value of parameter 'EXIT_NAME'.
    It will show you the BADI for that transaction.
 
 
 

 
 
 
Thanks & Regards
Durga  Prasad
 
 
 

Friday, December 4, 2009

OBBH Substitution FI

OBBH- FI Substitution Rules Transaction code

User exit for Substitution ZGGBS000

 

When u add a routine in the OBBH you need to define that in the user exit as below:

Definition:

 

 

FORM Code:

 

  

 


 


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
.



Program to read the Excel File to internal Table

REPORT  ytestdp60
NO STANDARD PAGE HEADING
LINE-SIZE 256
LINE-COUNT 65
.


DATABEGIN OF his_tab OCCURS 0,
vbeln(
10),
  item(
10),
  price(
15),
      
END OF his_tab.

DATA: wa_upload LIKE his_tab.
DATA: wa_upload1 LIKE his_tab.

PARAMETERS: file LIKE rlgrap-filename DEFAULT 'D:\Corn 2007-12.xls'.
DATA : gt_intern  TYPE  alsmex_tabline OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS : <fs>.
DATA:  v_idx            TYPE i VALUE '1'.
DATA:  v_idx1            TYPE i VALUE '1'.
DATA: bdiff(10TYPE p DECIMALS 2.
DATA: sdif1(10TYPE p DECIMALS 2.
DATA: sdif2(10TYPE p DECIMALS 2.

AT SELECTION-SCREEN  ON VALUE-REQUEST FOR file.
  
PERFORM get_filename USING file.

START-
OF-SELECTION.
* Upload the Excel file .
  
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    
EXPORTING
      filename                      =  file
      i_begin_col                   = 
1
      i_begin_row                   = 
1
      i_end_col                     = 
29
      i_end_row                     = 
9999
    
TABLES
      intern                        = gt_intern
* EXCEPTIONS
*   INCONSISTENT_PARAMETERS       = 1
*   UPLOAD_OLE                    = 2
*   OTHERS                        = 3
            .
  
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  
ENDIF.

* format the data and upload into the itab.
  
LOOP AT gt_intern.
    
MOVE gt_intern-col TO v_idx.

    
ASSIGN COMPONENT v_idx OF STRUCTURE wa_upload TO <fs>.
    
MOVE gt_intern-value TO <fs>.

    
AT END OF row.
      
MOVE wa_upload TO his_tab.
      
APPEND his_tab. CLEAR his_tab.
    
ENDAT.
  
ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  get_filename
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FNAME    text
*----------------------------------------------------------------------*
FORM get_filename USING  p_fname.
***To read the file from Presentation Server
  
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    
EXPORTING
      program_name      = sy-repid
      dynpro_number     = syst-dynnr
      field_name        = p_fname
*     STATIC              = ' '
*      mask              = '*.XLS'
    
CHANGING
      file_name         = p_fname
    
EXCEPTIONS
      mask_too_long       = 
1
      
OTHERS              = 2  .
  
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.                    " get_filename