SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Read employee's infotypes



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 70
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri May 22, 2009 2:43 pm    Post subject: Read employee's infotypes Reply with quote

Source from: http: /abap4.altervista.org/downloads/ztreehr.txt

Code:
REPORT ztree NO STANDARD PAGE HEADING
             LINE-COUNT 65
             LINE-SIZE 80.

************************************************************************
*$*$------------------------------------------------------------------*>
*$*$                 Utility per la visualizzazione degli infotype    *>
*$*$                 del dipendente, utilizzando TREE                 *>
*$*$ |\\/\\//\/\\/|                                                   *>
*$*$ |        |        /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\   *>
*$*$ |        |       / Function     : Read employee's infotypes  |   *>
*$*$ |  (e) (e)      /  Transaction  : ZTREE                      |   *>
*$*$ |        _)    /   Program      : ZTREE                      |   *>
*$*$(c   ,_____\\  /    Dynpro       : 1000                       |   *>
*$*$  |  (__(    -<     Author       : Cantaro Luciano            |   *>
*$*$  |    /       \    E-mail       : [email protected] |   *>
*$*$  /____\\       \   Date         : 08 - Agosto - 2002         |   *>
*$*$  /      \\      \  Last change  : 08 - Agosto - 2002         |   *>
*$*$ /        \\      \___________________________________________/   *>
*$*$/          \\                                                     *>
*$*$------------------------------------------------------------------*>


*DECLARATIONS
TABLES: pa0001, pa0000, pa0002, pa0006, pa0008, t777d.


DATA: BEGIN OF it_pernr OCCURS 0,
      exp(1) VALUE '+',
      nachn(15),
      vorna(15),
      pernr LIKE pa0000-pernr,
      END OF it_pernr.

DATA: BEGIN OF it_info OCCURS 0,
      exp(1) VALUE '+',
      pernr LIKE pa0000-pernr,
      itext(35),
      infotype(6),
      END OF it_info.

DATA: it_t777d LIKE t777d OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF pannnn OCCURS 0,
      pernr LIKE pa0000-pernr,
      begda LIKE pa0000-begda,
      endda LIKE pa0000-endda,
      infty LIKE t777d-infty,
      END OF pannnn.


DATA: g_field(40) TYPE c,
      testo(40) TYPE c.

DATA: BEGIN OF page,
        scrlline LIKE syst-lilli,      "scroll line to top of screen
        cursline LIKE syst-lilli,      "line to put cursor on
        hdrlines TYPE i,               "lines in header + 1
        twohdrs TYPE i,                "two headers on screen
        cpostop TYPE i,                "position of cursor from top
        cposbot TYPE i,                "position of cursor from bottom
        cposit TYPE i,                 "position on the screen
        pagno TYPE i,                  "pageno of line
        pgelines TYPE i,               "lines used so far
      END OF page.


*SCREEN
SELECTION-SCREEN BEGIN OF BLOCK bl_1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: so_pernr FOR pa0000-pernr MATCHCODE OBJECT prem.
SELECTION-SCREEN END OF BLOCK bl_1.



*FLOW LOGIC
START-OF-SELECTION.
  PERFORM build_it_data.

END-OF-SELECTION.
  PERFORM write_report.

TOP-OF-PAGE.
  PERFORM top_of_page.

TOP-OF-PAGE DURING LINE-SELECTION.
  PERFORM top_of_page.

AT LINE-SELECTION.
  g_field = space.
  GET CURSOR FIELD g_field.
  PERFORM line_selection.






*ROUTINES

*---------------------------------------------------------------------*
*       FORM BUILD_IT_DATA                                            *
*---------------------------------------------------------------------*
FORM build_it_data.


  SELECT * INTO TABLE it_t777d FROM t777d.

  LOOP AT it_t777d.
    IF it_t777d-dbtab+0(2) <> 'PA'.
      DELETE it_t777d.
    ENDIF.
  ENDLOOP.


  SELECT * INTO CORRESPONDING FIELDS OF TABLE it_pernr FROM pa0003
           WHERE pernr IN so_pernr.


  IF it_pernr[] IS INITIAL.
    WRITE: / 'Cid inesistente'.
  ELSE.
    LOOP AT it_pernr.
      MOVE '+' TO it_pernr-exp.
      SELECT SINGLE nachn vorna INTO (it_pernr-nachn, it_pernr-vorna)
             FROM pa0002 WHERE pernr = it_pernr-pernr.
      MODIFY it_pernr.
    ENDLOOP.
  ENDIF.

ENDFORM.



*---------------------------------------------------------------------*
*       FORM WRITE_REPORT                                             *
*---------------------------------------------------------------------*
FORM write_report.




  syst-lsind = '0'.

  PERFORM ramo_dipendente.

  ULINE.





ENDFORM.

*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
*       FORM LINE_SELECTION                                           *
*---------------------------------------------------------------------*
FORM line_selection.

  DATA: tabella(6),
        wannnn(500).

  PERFORM set_scroll_line.

  CASE g_field.
    WHEN 'IT_PERNR-EXP'.
      READ TABLE it_pernr WITH KEY pernr = it_pernr-pernr.
      LOOP AT it_pernr WHERE pernr = it_pernr-pernr.
        IF it_pernr-exp = '-'.
          it_pernr-exp = '+'.
        ELSE.
          it_pernr-exp = '-'.
        ENDIF.
        MODIFY it_pernr INDEX syst-tabix.
      ENDLOOP.
    WHEN 'IT_INFO-EXP'.
      LOOP AT it_info WHERE infotype = it_info-infotype
                        AND pernr = it_info-pernr.
        IF it_info-exp = '-'.
          it_info-exp = '+'.
        ELSE.
          it_info-exp = '-'.
        ENDIF.
        MODIFY it_info INDEX syst-tabix.
      ENDLOOP.
    WHEN 'PANNNN-BEGDA'.
      READ TABLE pannnn WITH KEY pernr = pannnn-pernr
                                 infty = pannnn-infty
                                 begda = pannnn-begda.
      IF sy-subrc = 0.
        SET PARAMETER ID 'ITP' FIELD pannnn-infty.
        SET PARAMETER ID 'PER' FIELD pannnn-pernr.
        SET PARAMETER ID 'BEG' FIELD pannnn-begda.
        SET PARAMETER ID 'END' FIELD pannnn-endda.
        SET PARAMETER ID 'FCD' FIELD 'DIS'.

        CALL TRANSACTION 'PA30' AND SKIP FIRST SCREEN.
      ELSE.
        MESSAGE i000(db) WITH 'Record non presente'.
      ENDIF.

  ENDCASE.

  PERFORM write_report.
  PERFORM position_list.

ENDFORM.
*---------------------------------------------------------------------*
*       FORM SET_SCROLL_LINE                                          *
* determine the correct line to scroll the re-written report to, so   *
* that the user is returned to the same spot on the screen            *
* if user is mid way between pages, ie two headers are visable on the *
* screen, check if they are on the secondary page and adjust the      *
* scroll variable accordingly so as not to jump up lines because the  *
* scroll variable will be out by the number of lines in the extra hdr *
*---------------------------------------------------------------------*
FORM set_scroll_line.
  page-cursline = syst-lilli.
  page-scrlline = syst-lilli - ( syst-curow - page-hdrlines ).
  page-pgelines = ( page-pagno - 1 ) * syst-linct.
  page-cpostop = ( page-scrlline + syst-curow ) - page-pgelines.
  page-cposbot = ( page-scrlline - syst-curow ) - page-pgelines.
  page-cposit = page-cpostop + page-cposbot.
  page-twohdrs = page-hdrlines * 2.
  IF page-cposit LT page-twohdrs.
    page-scrlline = page-scrlline + 1.
  ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM POSITION_LIST                                            *
*---------------------------------------------------------------------*
FORM position_list.
  CALL FUNCTION 'LIST_SCROLL_LINE_TOPMOST'
       EXPORTING
            list_index = 1
            list_line  = page-scrlline
       EXCEPTIONS
            OTHERS     = 1.
  CHECK syst-subrc = 0.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM TOP_OF_PAGE                                              *
*---------------------------------------------------------------------*
FORM top_of_page.
* set page-hdrlines = lines in header + 1 system generated blank line
  page-hdrlines = 5.
  ULINE.
  WRITE : /1 syst-vline, 'DOSSIER'(002), AT syst-linsz syst-vline.
  WRITE : /1 syst-vline, 'DIPENDENTE'(003), AT syst-linsz syst-vline.
  ULINE.
ENDFORM.

*
*&---------------------------------------------------------------------*
*&      Form  RAMO_DIPENDENTE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ramo_dipendente.


  LOOP AT it_pernr.
    AT NEW pernr.
      FORMAT INTENSIFIED OFF.
      WRITE: /1 syst-vline NO-GAP,
                '[' NO-GAP,
                it_pernr-exp NO-GAP HOTSPOT ON,
                ']'.
      FORMAT INTENSIFIED ON.
      WRITE:     it_pernr-pernr COLOR 2,
                 ' ',
                 it_pernr-nachn,
                 ' ',
                 it_pernr-vorna,
              AT syst-linsz syst-vline.
      page-pagno = syst-pagno.
      HIDE: it_pernr-pernr, page-pagno.
    ENDAT.
    IF it_pernr-exp = '-'.

      PERFORM ramo_infotypes.

    ELSE.

      LOOP AT it_info WHERE pernr = it_pernr-pernr
                        AND exp = '-'.
        it_info-exp = '+'.
        MODIFY it_info.
      ENDLOOP.

    ENDIF.
  ENDLOOP.


ENDFORM.                    " RAMO_DIPENDENTE

*
*&---------------------------------------------------------------------*
*&      Form  RAMO_INFOTYPES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ramo_infotypes.


  READ TABLE it_info WITH KEY pernr = it_pernr-pernr.

  IF sy-subrc <> 0.
    PERFORM carica_info_dipendente.
  ENDIF.

  FORMAT COLOR OFF.
  LOOP AT it_info WHERE pernr = it_pernr-pernr.
    AT NEW infotype.
      WRITE: /1 syst-vline,
              3 syst-vline,
              4 '---',
              7 '[' NO-GAP,
              8 it_info-exp NO-GAP HOTSPOT ON,
              ']',
              it_info-infotype COLOR 3,
              it_info-itext,
             AT syst-linsz syst-vline.
      HIDE: it_info-infotype, it_info-pernr, page-pagno.
    ENDAT.
    IF it_info-exp = '-'.

      PERFORM ramo_records.

    ENDIF.
  ENDLOOP.


ENDFORM.                    " RAMO_INFOTYPES

*
*&---------------------------------------------------------------------*
*&      Form  CARICA_INFO_DIPENDENTE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM carica_info_dipendente.

  DATA: v_pernr LIKE pa0000-pernr.

  CLEAR it_info.
  LOOP AT it_t777d.
    SELECT SINGLE pernr INTO v_pernr FROM (it_t777d-dbtab) WHERE pernr
                                                      = it_pernr-pernr.
    IF sy-subrc = 0.
      MOVE it_t777d-dbtab TO it_info-infotype.
      MOVE '+' TO it_info-exp.
      MOVE it_pernr-pernr TO it_info-pernr.
      SELECT SINGLE itext INTO it_info-itext FROM t582s
             WHERE infty = it_t777d-infty
               AND sprsl = sy-langu.
      APPEND it_info.
      CLEAR it_info.
    ENDIF.
  ENDLOOP.


ENDFORM.                    " CARICA_INFO_DIPENDENTE

*
*&---------------------------------------------------------------------*
*&      Form  RAMO_RECORDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ramo_records.

  CLEAR pannnn.
  SELECT pernr begda endda INTO pannnn
   FROM (it_info-infotype) WHERE pernr = it_pernr-pernr.
    WRITE: /1 syst-vline,
            3 syst-vline,
            8 syst-vline,
            9 '--------',
            18 pannnn-begda HOTSPOT ON,
            ' - ',
            32 pannnn-endda,
           AT syst-linsz syst-vline.
    MOVE it_info-infotype+2(4) TO pannnn-infty.
    HIDE: pannnn-begda, pannnn-endda,
          pannnn-infty, pannnn-pernr, page-pagno.
    APPEND pannnn.
    CLEAR  pannnn.
  ENDSELECT.


ENDFORM.                    " RAMO_RECORDS

*
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.