Translate

Wednesday, 7 November 2012

SAP ABAP TIPS


1.   Refreshing Data on reports.



      LO_SELTAB LIKE RSPARAMS OCCURS 0 WITH HEADER LINE.

LO_REPID = SY-REPID.
CALL FUNCTION
'RS_REFRESH_FROM_SELECTOPTIONS'
      EXPORTING
           CURR_REPORT     = LO_REPID
      TABLES
           SELECTION_TABLE = LO_SELTAB
      EXCEPTIONS
          NOT_FOUND       = 1
          NO_REPORT       = 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.
 SUBMIT (SY-REPID)
WITH SELECTION-TABLE LO_SELTAB.

2.Dynamic selection screens


*--- SELECTION OPTIONS ---------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK SO WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,"Sales order number   
               S_VBELND FOR LIKP-VBELN,"Delivery number     
               S_VBELNI FOR VBRK-VBELN,"Invoice number      
               S_VBELNP FOR VBKD-BSTKD."PO number           
SELECTION-SCREEN END OF BLOCK SO.                            

*--- EVENT AT SCREEN OUTPUT -------------------------------
AT SELECTION-SCREEN OUTPUT.                                       
  CASE SY-TCODE.                                                  
    WHEN 'ZEDI6'.                                                  
      LOOP AT SCREEN.                                             
        CASE SCREEN-GROUP4.                                       
          WHEN '001'.                  "Sales order select        
            SCREEN-ACTIVE = '1'.       "1=Active, 0=Don't display 
            MODIFY SCREEN.                                        
          WHEN '002'.                  "Delivery select           
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display 
            MODIFY SCREEN.                                        
          WHEN '003'.                  "Invoice select            
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display 
            MODIFY SCREEN.                                         
          WHEN '004'.                  "PO Select                 
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display 
            MODIFY SCREEN.                                        
        ENDCASE.                                                   
      ENDLOOP.                                                    
    WHEN 'ZEDI6D'.                     "Delivery select            
      LOOP AT SCREEN.                                               
        CASE SCREEN-GROUP4.                                        
          WHEN '001'.                  "Sales order select         
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display  
            MODIFY SCREEN.                                         
          WHEN '002'.                  "Delivery select            
            SCREEN-ACTIVE = '1'.       "1=Active, 0=Don't display  
            MODIFY SCREEN.                                         
          WHEN '003'.                  "Invoice select             
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display  
            MODIFY SCREEN.                                         
          WHEN '004'.                  "PO Select                   
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display  
            MODIFY SCREEN.                                         
        ENDCASE.                                                   
      ENDLOOP.                                                      
    WHEN 'ZEDI6I'.                     "Invoice select                  
      LOOP AT SCREEN.                                                   
        CASE SCREEN-GROUP4.                                              
          WHEN '001'.                  "Sales order select              
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display       
            MODIFY SCREEN.                                               
          WHEN '002'.                  "Delivery select                 
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display       
            MODIFY SCREEN.                                              
          WHEN '003'.                  "Invoice select                  
            SCREEN-ACTIVE = '1'.       "1=Active, 0=Don't display       
            MODIFY SCREEN.                                              
          WHEN '004'.                  "PO Select                        
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display       
            MODIFY SCREEN.                                              
        ENDCASE.                                                        
      ENDLOOP.                                                           
    WHEN 'ZEDI6P'.                     "PO select                   
      LOOP AT SCREEN.                                               
        CASE SCREEN-GROUP4.                                          
          WHEN '001'.                  "Sales order select          
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display   
            MODIFY SCREEN.                                          
          WHEN '002'.                  "Delivery select             
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display   
            MODIFY SCREEN.                                          
          WHEN '003'.                  "Invoice select               
            SCREEN-ACTIVE = '0'.       "1=Active, 0=Don't display   
            MODIFY SCREEN.                                          
          WHEN '004'.                  "PO Select                   
            SCREEN-ACTIVE = '1'.       "1=Active, 0=Don't display   
            MODIFY SCREEN.                                          
        ENDCASE.                                                    
      ENDLOOP.                                                      
  ENDCASE.                                                          

3.    Retrieving the email address of an SAP user


call function 'SUSR_USER_ADDRESS_READ'
         exporting
              user_name              = sy-uname
              read_db_directly       = ' '
         importing
              user_address           = addr3_val
              user_usr03             = usr03
         exceptions
              user_address_not_found = 1
              others                 = 2.
    if sy-subrc = 0.

      call function 'ADDR_PERS_COMP_COMM_GET'
           exporting
                address_number = addr3_val-addrnumber
                language       = sy-langu
                person_number  = addr3_val-persnumber
                table_type     = 'ADSMTP'
           tables
                comm_table     = in_email
           exceptions
                others         = 1.

      if sy-subrc = 0.
        describe table in_email lines l_tfill.

        if l_tfill = 0.
          message i140(qm).
          raise action_stopped.
        Else.
***** HERES EMAIL ADDRESS – in_email-smtp
        endif.
      endif.
    endif.


4.GUI STATUS

BACK       %EX        RW         PRI        %SC        %SC+       P--        P-         P+         P++







No comments: