Make your own free website on Tripod.com

Niraj Visnoi site of SAP

SAP Code

Home
About Me
Contact Me
My Resume
SAP Code
Visual Basic Links

SAP Code

Purchase Order History Mass Display 

Instead of checking your Purchase Order History one at a time, you can now mass display or print them with this customized abap report.

Mass display or print Purchase Order History
                                    *
                                    *  You can request report by :
                                    *  1.  Change date
                                    *  2.  User Name
                                    *  3.  Purchase Order Number
                                    *  4.  Vendor Code
                                    *
                                    * 
                                    REPORT ZPOCHANGE LINE-SIZE 132 NO STANDARD PAGE HEADING
                                                     LINE-COUNT 065(001)
                                                     MESSAGE-ID VR.
                                    
                                    TABLES: DD04T,
                                            CDHDR,
                                            CDPOS,
                                            DD03L,
                                            DD41V,
                                            T685T,
                                            VBPA,
                                            TPART,
                                            KONVC,
                                            EKKO.
                                    
                                    SELECT-OPTIONS: XUDATE FOR CDHDR-UDATE,
                                                    XNAME  FOR CDHDR-USERNAME,
                                                    XEBELN FOR EKKO-EBELN,
                                                    XLIFNR FOR EKKO-LIFNR.
                                    
                                    SELECTION-SCREEN SKIP.
                                    * TEXT-001 - Sorting Sequence
                                    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
                                    PARAMETERS: SUDATE RADIOBUTTON GROUP R1,
                                                SNAME  RADIOBUTTON GROUP R1,
                                                SOBID  RADIOBUTTON GROUP R1.
                                    SELECTION-SCREEN END OF BLOCK BLK1.
                                    
                                    DATA: WFLAG,
                                          WCHANGENR LIKE CDHDR-CHANGENR.
                                    
                                    DATA: INDTEXT(60) TYPE C.
                                    
                                    DATA: BEGIN OF ICDHDR OCCURS 50.
                                            INCLUDE STRUCTURE CDHDR.
                                    DATA: END OF ICDHDR.
                                    
                                    DATA: BEGIN OF ICDSHW OCCURS 50.
                                            INCLUDE STRUCTURE CDSHW.
                                    DATA: END OF ICDSHW.
                                    
                                    DATA: BEGIN OF EKKEY,
                                            EBELN LIKE EKET-EBELN,
                                            EBELP LIKE EKET-EBELP,
                                            ETENR LIKE EKET-ETENR,
                                    
                                          END OF EKKEY.
                                    
                                    DATA: BEGIN OF ITAB OCCURS 50,
                                            BEGIN OF EKKEY,
                                              EBELN LIKE EKET-EBELN,
                                              EBELP LIKE EKET-EBELP,
                                    
                                              ETENR LIKE EKET-ETENR,
                                            END OF EKKEY,
                                            CHANGENR LIKE CDHDR-CHANGENR,
                                            UDATE    LIKE CDHDR-UDATE,
                                            UTIME    LIKE CDHDR-UTIME,
                                            USERNAME LIKE CDHDR-USERNAME,
                                            CHNGIND  LIKE CDSHW-CHNGIND,
                                            FTEXT    LIKE CDSHW-FTEXT,
                                            OUTLEN   LIKE CDSHW-OUTLEN,
                                            F_OLD    LIKE CDSHW-F_OLD,
                                            F_NEW    LIKE CDSHW-F_NEW,
                                          END OF ITAB.
                                    
                                    DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.
                                    
                                    FIELD-SYMBOLS: <F_OLD>, <F_NEW>.
                                    
                                    SELECT * FROM EKKO WHERE EBELN IN XEBELN AND
                                                            
                                    LIFNR IN XLIFNR.
                                      CLEAR CDHDR.
                                      CLEAR CDPOS.
                                      CDHDR-OBJECTCLAS = 'EINKBELEG'.
                                      CDHDR-OBJECTID   = EKKO-EBELN.
                                      PERFORM GETCHGDOCS.
                                    ENDSELECT.
                                    
                                    IF SUDATE = 'X'.
                                      SORT ITAB BY UDATE EKKEY-EBELN CHANGENR EKKEY-EBELP
                                                   EKKEY-ETENR.
                                    ELSEIF SNAME = 'X'.
                                      SORT ITAB BY USERNAME EKKEY-EBELN CHANGENR EKKEY-EBELP
                                                   EKKEY-ETENR.
                                    ELSE.
                                      SORT ITAB BY EKKEY-EBELN CHANGENR EKKEY-EBELP EKKEY-ETENR.
                                    ENDIF.
                                    
                                    LOOP AT ITAB.
                                      CLEAR: INDTEXT, EKKEY.
                                      CASE ITAB-CHNGIND.
                                        WHEN 'U'.
                                            INDTEXT(50) = ITAB-FTEXT.
                                            INDTEXT+51  = TEXT-020.
                                            CONDENSE INDTEXT.
                                        WHEN 'D'.
                                            INDTEXT = TEXT-021.
                                        WHEN 'E'.
                                            INDTEXT(5) = ITAB-FTEXT.
                                            INDTEXT+51 = TEXT-021.
                                            CONDENSE INDTEXT.
                                          WHEN 'I'.
                                            INDTEXT = TEXT-022.
                                        ENDCASE.
                                        RESERVE 4 LINES.
                                        IF WCHANGENR NE ITAB-CHANGENR.
                                          WCHANGENR = ITAB-CHANGENR.
                                          EKKEY = ITAB-EKKEY.
                                          WRITE:/ ITAB-UDATE UNDER 'Change Date',
                                                  ITAB-UTIME UNDER 'Time',
                                                  ITAB-USERNAME UNDER 'User Name',
                                                  ITAB-EKKEY-EBELN UNDER 'PO No',
                                                  ITAB-EKKEY-EBELP UNDER 'Item',
                                                  ITAB-EKKEY-ETENR UNDER 'Sch No',
                                                  INDTEXT     UNDER 'Changes'.
                                        ELSEIF ITAB-EKKEY NE EKKEY.
                                          WRITE:/ ITAB-EKKEY-EBELP UNDER 'Item',
                                                  ITAB-EKKEY-ETENR UNDER 'Sch No',
                                                  INDTEXT     UNDER 'Changes'.
                                    
                                        ENDIF.
                                    
                                        CASE ITAB-CHNGIND.
                                          WHEN 'U'.
                                            ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO <F_OLD>.
                                            ASSIGN ITAB-F_NEW(ITAB-OUTLEN) TO <F_NEW>.
                                            WRITE: / TEXT-023  UNDER 'Changes',
                                                     <F_OLD>.
                                            WRITE: / TEXT-024 UNDER 'Changes',
                                                     <F_NEW>.
                                          WHEN 'E'.
                                            ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO <F_OLD>.
                                            WRITE: TEXT-023 UNDER 'Changes',
                                                   <F_OLD>.
                                        ENDCASE.
                                        SKIP.
                                    ENDLOOP.
                                    
                                    
                                    TOP-OF-PAGE.
                                    WRITE:/ SY-DATUM,SY-UZEIT,
                                           50 'P U R C H A S E  O R D E R   H I S T O R Y',
                                          120 'Page', SY-PAGNO.
                                    WRITE: / SY-REPID,
                                             60 'Purchase Orders Changes'.
                                    SKIP.
                                    ULINE.
                                    IF SUDATE = 'X'.
                                      WRITE:/001 'Change Date',
                                             014 'Time',
                                             024 'User Name',
                                             038 'PO No',
                                             050 'Item',
                                             057 'Sch No',
                                             065 'Changes'.
                                    ELSEIF SOBID = 'X'.
                                      WRITE:/001 'PO No',
                                             013 'Item',
                                             020 'Sch No',
                                             028 'Change Date',
                                             041 'Time',
                                             051 'User Name',
                                             065 'Changes'.
                                    ELSE.
                                      WRITE:/001 'User Name',
                                             015 'Change Date',
                                             028 'Time',
                                             038 'PO No',
                                             050 'Item',
                                             057 'Sch No',
                                             065 'Changes'.
                                    ENDIF.
                                    ULINE.
                                    
                                    FORM GETCHGDOCS.
                                      CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
                                           EXPORTING
                                                DATE_OF_CHANGE    = CDHDR-UDATE
                                                OBJECTCLASS       = CDHDR-OBJECTCLAS
                                                OBJECTID         
                                    = CDHDR-OBJECTID
                                                TIME_OF_CHANGE    = CDHDR-UTIME
                                                USERNAME         
                                    = CDHDR-USERNAME
                                           TABLES
                                                I_CDHDR          
                                    = ICDHDR
                                           EXCEPTIONS
                                                NO_POSITION_FOUND = 1
                                                OTHERS           
                                    = 2.
                                    
                                      CHECK SY-SUBRC EQ 0.
                                      DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.
                                      CHECK NOT ICDHDR[] IS INITIAL.
                                      LOOP AT ICDHDR.
                                        CHECK ICDHDR-UDATE IN XUDATE.
                                        CHECK ICDHDR-USERNAME IN XNAME.
                                        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
                                                     EXPORTING  CHANGENUMBER      
                                    = ICDHDR-CHANGENR
                                                     IMPORTING  HEADER            
                                    = CDHDR
                                                     TABLES    
                                    EDITPOS            = ICDSHW
                                                     EXCEPTIONS NO_POSITION_FOUND 
                                    = 1
                                                               
                                    OTHERS             = 2.
                                        CHECK SY-SUBRC EQ 0.
                                        LOOP AT ICDSHW.
                                          CHECK ICDSHW-TEXT_CASE EQ SPACE.
                                          MOVE-CORRESPONDING ICDSHW TO ITAB.
                                          MOVE-CORRESPONDING ICDHDR TO ITAB.
                                          MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.
                                          APPEND ITAB.
                                        ENDLOOP.
                                      ENDLOOP.
                                    ENDFORM.
                                    
                                    * END OF PROGRAM 
 
A
                                    demo program to create subscreen in 
your ABAP Program 
 
 
* A demo program to create subscreen in your ABAP Program
*
* This report will display the user last login date and time.
*
* Subscreen selection 1 : User Name
*                                2 : Last Login Date
*                                3 : Class Belong To
*

*
REPORT ZSUBSCREEN.
                                    
                                    TABLES: USR02,       "Logon data
                                            SSCRFIELDS.  "FIELDS ON SELECTION SCREENS
                                    *---------------------------------------------------------------
                                    * SUBSCREEN 1
                                    *---------------------------------------------------------------
                                    SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
                                    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
                                       SELECT-OPTIONS: USERNAME FOR USR02-BNAME.
                                    SELECTION-SCREEN END OF BLOCK B1.
                                    SELECTION-SCREEN END OF SCREEN 100.
                                    
                                    *---------------------------------------------------------------
                                    * SUBSCREEN 2
                                    *---------------------------------------------------------------
                                    SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
                                    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.
                                       SELECT-OPTIONS: LASTLOGI FOR USR02-TRDAT.
                                    SELECTION-SCREEN END OF BLOCK B2.
                                    SELECTION-SCREEN END OF SCREEN 200.
                                    
                                    *---------------------------------------------------------------
                                    * SUBSCREEN 3
                                    *---------------------------------------------------------------
                                    SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
                                    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.
                                       SELECT-OPTIONS: CLASSTYP FOR USR02-CLASS.
                                    SELECTION-SCREEN END OF BLOCK B3.
                                    SELECTION-SCREEN END OF SCREEN 300.
                                    
                                    * STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT
                                    SELECTION-SCREEN: FUNCTION KEY 1,
                                                      FUNCTION KEY 2.
                                    
                                    SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,
                                                      END OF BLOCK SUB.
                                    
                                    START-OF-SELECTION.
                                        SELECT * FROM USR02 WHERE BNAME IN USERNAME
                                                             
                                    AND ERDAT IN LASTLOGI
                                                             
                                    AND CLASS IN CLASSTYP.
                                           WRITE: / 'User ', USR02-BNAME,
                                                    'Last Login Date ', USR02-TRDAT,
                                                    'Last Login Time ', USR02-LTIME,
                                                    'CLASS ', USR02-CLASS.
                                        ENDSELECT.
                                    END-OF-SELECTION.
                                    
                                    INITIALIZATION.
                                    * SCREEN ICON LEFT AND RIGHT
                                      SSCRFIELDS-FUNCTXT_01 = '@0D@'.
                                      SSCRFIELDS-FUNCTXT_02 = '@0E@'.
                                      SUB-PROG = SY-REPID.
                                      SUB-DYNNR = 100.
                                    
                                    AT SELECTION-SCREEN.
                                      CASE SY-DYNNR.
                                    
                                        WHEN 100.
                                          IF SSCRFIELDS-UCOMM = 'FC01'.
                                            SUB-DYNNR = 300.
                                          ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
                                            SUB-DYNNR = 200.
                                          ENDIF.
                                    
                                        WHEN 200.
                                          IF SSCRFIELDS-UCOMM = 'FC01'.
                                            SUB-DYNNR = 100.
                                          ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
                                            SUB-DYNNR = 300.
                                          ENDIF.
                                    
                                        WHEN 300.
                                          IF SSCRFIELDS-UCOMM = 'FC01'.
                                            SUB-DYNNR = 200.
                                          ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
                                            SUB-DYNNR = 100.
                                          ENDIF.
                                      ENDCASE.
 
 
 
 
Finding the user-exits of a 
SAP transaction 
 
* Finding
                                    the user-exits of a SAP transaction code
                                    *
                                    * Enter the transaction code in which you are looking for the user-exit
                                    * and it will list you the list of user-exits in the transaction code.
                                    * Also a drill down is possible which will help you to branch to SMOD.
                                    *
                                    * Written by : SAP Basis, ABAP Programming and Other IMG Stuff
                                    
                                    
                                    report zuserexit no standard page heading.
                                    tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
                                             tables : tstct.
                                    data : jtab like tadir occurs 0 with header line.
                                    data : field1(30).
                                    data : v_devclass like tadir-devclass.
                                    parameters : p_tcode like tstc-tcode obligatory.
                                    
                                    select single * from tstc where tcode eq p_tcode.
                                    if sy-subrc eq 0.
                                       select single * from tadir where pgmid = 'R3TR'
                                                        and object
                                    = 'PROG'
                                                        and obj_name
                                    = tstc-pgmna.
                                       move : tadir-devclass to v_devclass.
                                          if sy-subrc ne 0.
                                             select single * from trdir where name = tstc-pgmna.
                                             if trdir-subc eq 'F'.
                                                select single * from tfdir where pname = tstc-pgmna.
                                                select single * from enlfdir where funcname =
                                                tfdir-funcname.
                                                select single * from tadir where pgmid = 'R3TR'
                                                                  
                                    and object = 'FUGR'
                                                                  
                                    and obj_name eq enlfdir-area.
                                    
                                                move : tadir-devclass to v_devclass.
                                              endif.
                                           endif.
                                           select * from tadir into table jtab
                                                         where
                                    pgmid = 'R3TR'
                                                          
                                    and object = 'SMOD'
                                                          
                                    and devclass = v_devclass.
                                            select single * from tstct where sprsl eq sy-langu and
                                                                            
                                    tcode eq p_tcode.
                                            format color col_positive intensified off.
                                            write:/(19) 'Transaction Code - ',
                                                 20(20) p_tcode,
                                                 45(50) tstct-ttext.
                                                        skip.
                                            if not jtab[] is initial.
                                               write:/(95) sy-uline.
                                               format color col_heading intensified on.
                                               write:/1 sy-vline,
                                                      2 'Exit Name',
                                                     21 sy-vline ,
                                                     22 'Description',
                                                     95 sy-vline.
                                               write:/(95) sy-uline.
                                               loop at jtab.
                                                  select single * from modsapt
                                                         where
                                    sprsl = sy-langu and
                                                               
                                    name = jtab-obj_name.
                                                       format color
                                    col_normal intensified off.
                                                       write:/1 sy-vline,
                                                             
                                    2 jtab-obj_name hotspot on,
                                                            
                                    21 sy-vline ,
                                                            
                                    22 modsapt-modtext,
                                                            
                                    95 sy-vline.
                                               endloop.
                                               write:/(95) sy-uline.
                                               describe table jtab.
                                               skip.
                                               format color col_total intensified on.
                                               write:/ 'No of Exits:' , sy-tfill.
                                            else.
                                               format color col_negative intensified on.
                                               write:/(95) 'No User Exit exists'.
                                            endif.
                                          else.
                                              format color col_negative intensified on.
                                              write:/(95) 'Transaction Code Does Not Exist'.
                                          endif.
                                    
                                    at line-selection.
                                       get cursor field field1.
                                       check field1(4) eq 'JTAB'.
                                       set parameter id 'MON' field sy-lisel+1(10).
                                       call transaction 'SMOD' and skip first   screen.
                                    
                                    *---End of Program
Contributed by: 
SAP Basis, ABAP Programming and Other IMG Stuff

Enter supporting content here