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

Infotype cancelation



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri May 22, 2009 3:00 pm    Post subject: Infotype cancelation Reply with quote

Code:
REPORT ZHR_MD_CANINFO .

*----------------------------------------------------------------------*
*                                                                      *
*            Programma per cancellazione infotype                      *
*                                                                      *
* Autore  : Luciano Cantaro                                            *
* Data creaz.  : 28/09/2001                                            *
* Data ul.mod. : 29/09/2001                                            *
*                                                                      *
*----------------------------------------------------------------------*



TABLES: T582A,
        PA0001,
        P0001,
        PA0004,
        PA0006,
        pa0008,
        PA0009,
        PA0011,
        PA0014,
        PA0015,
        PA0017,
        PA0019,
        PA0022,
        PA0028,
        PA0035,
        PA0040,
        PA0041,
        PA0057,
        PA0105,
        PA0128,
        PA0154,
        PA0155,
        PA0156,
        PA0159,
        PA0160,
        PA0548,
        PA2001,
        PA2012,
        PA9001,
        PA9901,
        PA9910,
        PA9911,
        PA9912,
        PA9920,
        PA9922,
        PA9924,
        PA9925.

DATA: BEGIN OF TINFO OCCURS 0,
      INFOTYPE(4) TYPE C,
      RECORD(6) TYPE N,
      END OF TINFO.

DATA: RISP(1) TYPE N,
      TESTO(80),
      CONT(6) TYPE N.



DATA : BEGIN OF TDOC_OCC OCCURS 0,
       NUMERO(6) TYPE N,
       INFO(6),
       PERNR LIKE PA0000-PERNR,
       BEGDA LIKE PA0000-BEGDA,
       ENDDA LIKE PA0000-ENDDA,
       UNAME LIKE PA0000-UNAME,
       SUBTY LIKE PA0000-SUBTY,
       END OF TDOC_OCC.

DATA: BEGIN OF TDOC_APPO OCCURS 0,
      FILL(03).
        INCLUDE STRUCTURE PAKEY.
        INCLUDE STRUCTURE PSHD1.
DATA: FILL2(1000).
DATA: END OF TDOC_APPO.
DATA: NRO_IT(4) TYPE N.
DATA NOME_PA(6).


DATA : TESTATA LIKE HRFIELDNAM OCCURS 0 WITH HEADER LINE.


SELECTION-SCREEN: BEGIN OF BLOCK AA WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN: SKIP.
SELECT-OPTIONS: INFO FOR T582A-INFTY OBLIGATORY.
select-options: subty for pa0008-subty.
SELECT-OPTIONS: CID FOR PA0004-PERNR OBLIGATORY.
select-options: TIPODIP for P0001-PERSK. " OBLIGATORY.
*SELECT-OPTIONS: DATA FOR SY-DATUM. " default sy-datum.
*SELECT-OPTIONS: UTENTE FOR SY-UNAME. " default sy-uname.
SELECTION-SCREEN: END OF BLOCK AA.
************************************************************************
SELECTION-SCREEN: ULINE.
************************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK AB WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN: SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(15) TEXT-003  FOR FIELD P_TEST.
SELECTION-SCREEN POSITION 20.
PARAMETERS: P_TEST RADIOBUTTON GROUP 01.
SELECTION-SCREEN COMMENT 35(15) TEXT-004  FOR FIELD P_UPDT.
SELECTION-SCREEN POSITION 55.
PARAMETERS: P_UPDT RADIOBUTTON GROUP 01.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK AB.
************************************************************************



*flow


INITIALIZATION.


START-OF-SELECTION.

 if p_updt eq 'X'.
  PERFORM POPUP_UPDATE.
 endif.
  perform update_infotype.

END-OF-SELECTION.






*routines

*&---------------------------------------------------------------------*
*&      Form  cancella_infotype
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*



    FORM update_infotype.

      FIELD-SYMBOLS <table> TYPE table.
      nro_it = info-low.

      WHILE nro_it IN info.

        CONCATENATE 'PA' nro_it INTO nome_pa.


        SELECT * FROM (nome_pa) INTO tdoc_appo
                                WHERE pernr IN cid AND
                                      subty IN subty.
          SELECT SINGLE * FROM pa0001 INTO pa0001
                 WHERE pernr EQ tdoc_appo-pernr
                 AND begda LE tdoc_appo-endda
                 AND endda GE tdoc_appo-endda.
          IF sy-subrc <> 0.
            IF nro_it = '0156'.
              SELECT  * FROM pa0001 INTO pa0001
                     WHERE pernr EQ tdoc_appo-pernr
                     ORDER BY begda ASCENDING.
                EXIT.
              ENDSELECT.
              IF sy-subrc <> 0.
                MESSAGE e000(db) WITH tdoc_appo-pernr.
              ENDIF.
            ELSE.
              MESSAGE e000(db) WITH tdoc_appo-pernr.
            ENDIF.
          ENDIF.
          CHECK pa0001-persk IN tipodip.
          CONCATENATE 'IT' nro_it INTO tdoc_occ-info.
          MOVE tdoc_appo-pernr TO tdoc_occ-pernr.
          MOVE tdoc_appo-begda TO tdoc_occ-begda.
          MOVE tdoc_appo-endda TO tdoc_occ-endda.
          MOVE tdoc_appo-uname TO tdoc_occ-uname.
          MOVE tdoc_appo-subty TO tdoc_occ-subty.

          cont = cont + 1.
          MOVE cont TO tdoc_occ-numero.
          APPEND tdoc_occ. CLEAR tdoc_occ.
        ENDSELECT.

        nro_it = nro_it + 1.

      ENDWHILE.

      PERFORM testata.

      IF      ( '0000' IN info
             OR '0001' IN info
             OR '0002' IN info
             OR '0003' IN info
             OR '0007' IN info
             OR '0016'  IN info )
               OR risp NE '2'
               OR p_updt NE 'X'.
        PERFORM display_occ.
      ELSE.
        if '0008' in info.
         message s000(db).
         check not subty is initial.
         check not '0' in subty.
        endif.
        PERFORM update_occ.
      ENDIF.



    ENDFORM.                    " cancella_infotype
*&---------------------------------------------------------------------*
*&      Form  gestione
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

    FORM popup_update.

      CONCATENATE 'Cancelli DEFINITIVAMENTE' 'i record inseriti?' INTO
      testo SEPARATED BY space.

      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING

      titlebar  = 'Attenzione: Confermi Cancellazione Record?'

*   DIAGNOSE_OBJECT             = ' '
      text_question              =  testo

      text_button_2              = 'Si'

*   ICON_BUTTON_1               = ' '
      text_button_1               = 'No'

*   ICON_BUTTON_2               = ' '
*   DEFAULT_BUTTON              = '1'
      display_cancel_button       = 'X'

*   USERDEFINED_F1_HELP         = ' '
       start_column                = 25
       start_row                   = 6
*   POPUP_TYPE                  =
    IMPORTING

     answer                      = risp.






    ENDFORM.                    " popup
*&---------------------------------------------------------------------*
*&      Form  log_video
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
    FORM log_video.
      SKIP.
      SKIP.
      WRITE:/ sy-uline(46).

 WRITE: / '|', 'Infotype',  '|', '     Record cancellati' ,'         |'
                                                                       .

      LOOP AT TINFO.

        WRITE:/ sy-uline(46).
        WRITE:/ '|', '  ',TINFO-infotype.
        WRITE: ' |', '            ',TINFO-record, '            |'.

      ENDLOOP.
      WRITE:/ sy-uline(46).
    ENDFORM.                    " log_video
*&---------------------------------------------------------------------*
*&      Form  testata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
    FORM testata.
      testata-field  = 'Numero'. APPEND testata.
      testata-field  = 'INFOTYPE'. APPEND testata.
      testata-field  = 'C.I.D.'. APPEND testata.
      testata-field  = 'Inizio'. APPEND testata.
      testata-field  = 'Fine'. APPEND testata.
      testata-field  = 'User'. APPEND testata.
      testata-field  = 'SUBTYPE'. APPEND testata.

      CLEAR testata.
    ENDFORM.                    " testata
*&---------------------------------------------------------------------*
*&      Form  display_occ
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
    FORM display_occ.
      CALL FUNCTION 'DISPLAY_BASIC_LIST'
           EXPORTING
        basic_list_title   = 'Occorrenze secondo le selezioni date'
               file_name            = 'ITKILLER'
               lay_out              = 0
          TABLES
                data_tab             = tdoc_occ
                fieldname_tab        = testata
          EXCEPTIONS
               no_data_tab_entries  = 2
               OTHERS               = 5
                .

    ENDFORM.                    " display_occ
*---------------------------------------------------------------------*
*       FORM DISPLAY_OCC                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
    FORM update_occ.
      CALL FUNCTION 'DISPLAY_BASIC_LIST'
           EXPORTING
        basic_list_title   = 'Occorrenze secondo le selezioni date'
               file_name            = 'ITKILLER'
               lay_out              = 0
           dyn_pushbutton_text1 = 'Annulla Cancellazione'
           dyn_pushbutton_text2 = 'Cancella occorrenze'
          TABLES
                data_tab             = tdoc_occ
                fieldname_tab        = testata
          EXCEPTIONS
               no_data_tab_entries  = 2
               OTHERS               = 5
                .
      CASE sy-ucomm.
        WHEN 'BUT1'.
          EXIT.
        WHEN 'BUT2'.
          PERFORM update_final.
      ENDCASE.
    ENDFORM.                    " update_OCC
*&---------------------------------------------------------------------*
*&      Form  update_final
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
    FORM update_final.


      nro_it = info-low.

      WHILE nro_it IN info.

        CONCATENATE 'PA' nro_it INTO nome_pa.
        LOOP AT tdoc_occ.

          DELETE FROM (nome_pa) WHERE begda EQ tdoc_occ-begda
                                 AND  pernr EQ tdoc_occ-pernr
                                 AND  endda EQ tdoc_occ-endda
                                 AND  subty EQ tdoc_occ-subty.
          nro_it = nro_it + 1.
        ENDLOOP.
      ENDWHILE.
      IF sy-subrc EQ 0.
        MESSAGE ID 'RP' TYPE 'I' NUMBER 16 WITH 'Attenzione,'
                    'cancellazione avvenuta con successo' .
      ENDIF.
      EXIT.


    ENDFORM.                    " update_final
Back to top
View user's profile Send private message
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.