Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8620

Re: ABAP Tab

$
0
0

************************************************************************

*Program code  : ZHR07IFOTMBSAP_K

*Change history:

************************************************************************

REPORT zhrtest7_wagemap "USING DATABASE pnp

  MESSAGE-ID pn

  LINE-SIZE 1023

  LINE-COUNT 60(1)

  NO STANDARD PAGE HEADING.

 

 

************************************************************************

CONSTANTS:

***********

  high_date TYPE dats VALUE '99991231',

  low_date  TYPE dats VALUE '19000101'.

 

 

************************************************************************

TABLES:

*******

* for additional data extraction before uploading

  pernr,

  pa0000,

  pa0001,

  pa0002,

  pa0008,

  pa0014,

  pa0015,

  pa2010,

* table for obtaining substitute information

  hrp1001, hrp1013.

 

 

*for batch uploading

TABLES:

  rlgrap,

  t100.

 

 

************************************************************************

INFOTYPES:

**********

  0000, 0001, 0002, 0008, 2010, 0014, 0015.

 

 

************************************************************************

RANGES:

*******

* Employee group

  r_persg   FOR pa0001-persg, "Employee group

 

 

* Employee subgroup

  r_erlgso  FOR pa0001-persk, "ERL GS office

  r_erlgss  FOR pa0001-persk, "ERL GS shift

  r_erlexs  FOR pa0001-persk, "ERL Executive shift

  r_emasgso FOR pa0001-persk, "EMAS GS office

  r_emasgss FOR pa0001-persk, "EMAS GS shift

  r_emasexs FOR pa0001-persk. "EMAS Executive shift

 

 

 

 

************************************************************************

*Variable to store record read, rejected, ok flag for ws_upload,

*exception string.

DATA: intfpath       LIKE rlgrap-filename. "incoming flat file path

DATA: intfpath2      LIKE rlgrap-filename. "incoming flat file path

 

 

DATA: readok         TYPE c VALUE 'N'.

 

 

DATA: recread_tot(8) TYPE n.     "total record read

DATA: recrej_tot(8)  TYPE n.     "total record rejected

 

 

DATA: excepmsg1      TYPE string.

DATA: excepmsg2      TYPE string.

DATA: excepmsg3      TYPE string.

DATA: excepmsg_com   TYPE string.

 

 

DATA: searchres1        TYPE i.  "Search result for 'record created'

DATA: searchres2        TYPE i.  "Search result for 'record deleted'

 

 

DATA: acindi(5)      TYPE c.  "ot, meala, trana

 

 

DATA: recrej_ot(8)      TYPE n.  "total ot records rejected

DATA: recsucc_ot(8)     TYPE n.  "total ot record succeeded

DATA: recpart_ot(8)     TYPE n.  "total ot record with partial status

DATA: recdel_ot(8)      TYPE n.  "total ot record deleted

DATA: recnew_ot(8)      TYPE n.  "total ot new records

DATA: recnup_ot(8)      TYPE n.  "total ot record not uploaded

 

 

DATA: recrej_php(8)   TYPE n.  "total php records rejected

DATA: recsucc_php(8)  TYPE n.  "total php record succeeded

DATA: recpart_php(8)  TYPE n.  "total php record with partial status

DATA: recdel_php(8)   TYPE n.  "total php record deleted

DATA: recnew_php(8)   TYPE n.  "total php new records

DATA: recnup_php(8)   TYPE n.  "total php record not uploaded

 

 

DATA: recrej_ads(8)   TYPE n.  "total ads records rejected

DATA: recsucc_ads(8)  TYPE n.  "total ads record succeeded

DATA: recpart_ads(8)  TYPE n.  "total ads record with partial status

DATA: recdel_ads(8)   TYPE n.  "total ads record deleted

DATA: recnew_ads(8)   TYPE n.  "total ads new records

DATA: recnup_ads(8)   TYPE n.  "total ads record not uploaded

 

 

*Convert to C type to concatenate (used in bdc_transaction)

DATA: char1(4)   TYPE c.

DATA: char2(4)   TYPE c.

DATA: char3(4)   TYPE c.

DATA: othrschar(8)   TYPE c.

DATA: salarychar(10) TYPE c.

DATA: acdhrchar(8) TYPE c.

DATA: otunitchar(10) TYPE c.

DATA: otamtchar(18) TYPE c.

DATA: phpunitchar(10) TYPE c.

DATA: shiftunitchar(10) TYPE c.

DATA: shiftamtchar(18) TYPE c.

 

 

*Log file to be printed out and saved.

DATA: BEGIN OF logtab OCCURS 0,

      log TYPE string.

DATA: END OF logtab.

 

 

DATA outputtab(1500) TYPE c OCCURS 0.

 

 

* attributes for download of log file with the correct status

DATA: log_name LIKE rlgrap-filename.

DATA: log_type LIKE rlgrap-filetype.

DATA: flenlog TYPE i.

DATA: uploadstat TYPE string.

 

 

************************************************************************

DATA: BEGIN OF file2 OCCURS 0,

*From Microbus

  pdate(10)     TYPE c,            "posted date

  pernr(6)      TYPE c,            "employee num

  otdat(10)     TYPE c,            "ot date

* wagetype: 1-Normal Day, 2-Public Holiday, 3-Normal day with public

*           holiday rate, 4-Special Public Holiday

  mbwtype      TYPE c,            "wage type

* For sched/actual activity:

* 1-Off, 2-Rest, 3-Standby, 4-Duty, 5-Leave, 6 - Unjustified Leave

  scact        TYPE c,            "scheduled activity

  acact        TYPE c,            "actual activitiy

  acdhr(5)     TYPE c,            "actual duty hours

  othrs(5)     TYPE c,            "ot hours

  sdbtm(5)     TYPE c,            "scheduled duty begin time

  sdetm(5)     TYPE c,            "scheduled duty end time

  adbtm(5)     TYPE c,            "actual duty begin time

  adetm(5)     TYPE c,            "actual duty end time

  extra1(5)     TYPE c,                                     "extra1

  extra2(5)     TYPE c,                                     "extra2

  extra3(7)     TYPE c,                                     "extra3

  extra4(5)     TYPE c,                                     "extra4

  otleaveindi  TYPE c,            "OT or Additional Leave indicator

  othrs_cal(5) TYPE c,            "calculation for ot hours

  acdhr_cal(5) TYPE c.            "calculation for actual duty hours

DATA: END OF file2.

*{   INSERT         ECDK901215                                        1

DATA: BEGIN OF tmp_file2 OCCURS 0,

        P_STR_LENGTH(99) TYPE C,

      END OF tmp_file2.

*}   INSERT

 

 

*******************************************************koonhon**********

 

 

DATA: BEGIN OF file OCCURS 0,

*From Microbus

  pdate(8)     TYPE c,            "posted date

  pernr        LIKE pa2010-pernr, "employee num

  otdat(8)     TYPE c,            "ot date

* wagetype: 1-Normal Day, 2-Public Holiday, 3-Normal day with public

*           holiday rate, 4-Special Public Holiday

  mbwtype      TYPE c,            "wage type

* For sched/actual activity:

* 1-Off, 2-Rest, 3-Standby, 4-Duty, 5-Leave, 6 - Unjustified Leave

  scact        TYPE c,            "scheduled activity

  acact        TYPE c,            "actual activitiy

  acdhr(5)     TYPE c,            "actual duty hours

  othrs(5)     TYPE c,            "ot hours

  sdbtm(6)     TYPE c,            "scheduled duty begin time

  sdetm(6)     TYPE c,            "scheduled duty end time

  adbtm(6)     TYPE c,            "actual duty begin time

  adetm(6)     TYPE c,            "actual duty end time

  extra1(5)    TYPE c,

  extra2(5)    TYPE c,

  extra3(7)    TYPE c,

  extra4(5)    TYPE c,

 

 

  otleaveindi  TYPE c,            "OT or Additional Leave indicator

**shift type : 0-Not relevant, 1-Day to Day, 2-Day to Night,

**             3-Night to Day, 4-Night to Night

*From SAP

  salary       LIKE pa2010-stdaz, "LIKE pa0008-bet01, "salary

  werks        LIKE pa0001-werks, "Personnel area (company)

  persg        LIKE pa0001-persg, "Employee group

  persk        LIKE pa0001-persk, "Employee subgroup (grade)

  stat2        LIKE pa0000-stat2, "Employee status (3 : Active)

 

 

*additional processing

  wtype        LIKE pa2010-lgart, "SAP wage type for normal OT

  wtype2       LIKE pa2010-lgart, "SAP wage type for normal OT

  status       TYPE string,       "exception notes

* ADD-ON NOV 6003 {start}

  status2       TYPE string,       "exception notes

* ADD-ON NOV 6003 {end}

 

 

  phpwtype     LIKE pa2010-lgart, "SAP wage type for public holiday

  phpstat      TYPE string,       "status for public holiday

  adswtype     LIKE pa2010-lgart, "SAP wage type for actual duty shift

  adsstat      TYPE string,       "status for actual duty shift

  prevacact    TYPE c,            "previous actual activity

  nextacact    TYPE c,            "next actual activity

  prevotdat(8) TYPE c,            "previous OT date

  nextotdat(8) TYPE c,            "next OT date

  otunit       LIKE pa2010-anzhl, "OT value entry in unit

  otamt        LIKE pa2010-betrg, "OT value entry in amount

  phpunit      LIKE pa2010-anzhl, "PHP value entry in unit

  sdbtmindi(5) TYPE c,            "shift indicator for start time

  sdetmindi(5) TYPE c,            "shift indicator for end time

  shiftunit    LIKE pa2010-anzhl, "shift value entry in unit

  shiftamt     LIKE pa2010-betrg, "shift value entry in amount

  finalstart(6) TYPE c,   " yap

  finalend(6) TYPE c,     " yap

  cback(5) TYPE c.                                          " yap 6003

 

 

 

 

 

 

 

 

DATA: END OF file.

 

 

* KAF start

************************************************************************

DATA: BEGIN OF it_daph OCCURS 0,

*From Microbus

  pdate(8)     TYPE c,            "posted date

  pernr        LIKE pa2010-pernr,   "employee num

  otdat        LIKE file-otdat,

  mbwtype      TYPE c,            "wage type

  scact        TYPE c,            "scheduled activity

  acact        TYPE c,            "actual activitiy

  othrs        LIKE file-othrs,

*  prvmbwtype   TYPE c,

*  prvscact      TYPE c,

*  prvacact     TYPE c,

  extra3       LIKE file-extra3,

*  prvextra3   LIKE file-extra3,

  phrmks      TYPE c,

  phpaid      TYPE c,

  wtype       LIKE file-wtype,

  phpwtype    LIKE file-phpwtype,

  otmarks     TYPE c.

 

 

DATA: END OF it_daph.

 

 

DATA: BEGIN OF it_counter OCCURS 0,

pernr(6)      TYPE c,            "employee num

counter       TYPE i.

 

 

DATA: END OF it_counter.

 

 

**********************************************************************

*KAF end

DATA: temp LIKE file2-acdhr_cal.

DATA: temp1 LIKE file2-acdhr_cal.

DATA: temp2 LIKE file2-acdhr_cal.

* Work area for file

DATA: wa_file LIKE file.

 

 

* Data to obtain previous and next otdates.

DATA: prevotdat LIKE file-otdat.

DATA: nextotdat LIKE file-otdat.

DATA: prevotdat_char(10) TYPE c.

DATA: nextotdat_char(10) TYPE c.

 

 

 

 

* Data to compare time

DATA: comparison_result1 TYPE c.

DATA: comparison_result2 TYPE c.

DATA: currtim_char(8) TYPE c.

DATA: lowtim_0700 LIKE sy-uzeit VALUE '065900'.

DATA: hitim_1900  LIKE sy-uzeit VALUE '185900'.

DATA: currtim_int LIKE sy-uzeit.

 

 

* Yap {start}

DATA: sdbtm_int TYPE sy-uzeit.

DATA: sdetm_int TYPE sy-uzeit.

DATA: adbtm_int TYPE sy-uzeit.

DATA: adetm_int TYPE sy-uzeit.

DATA: othrs_int TYPE sy-uzeit.

DATA: start_int TYPE sy-uzeit.

DATA: ph_pay TYPE c.

DATA: ph_callback TYPE c.

 

 

DATA: start_tm(6) TYPE c.

DATA: per_start_tm(6) TYPE c.

DATA: minus_ot TYPE sy-uzeit.

DATA: end_int LIKE sy-uzeit.

DATA: end_tm(6) TYPE c.

DATA: cal_ot_sys TYPE sy-uzeit.

DATA: join_ot(6) type c.

DATA: cal_othr(2) type c.

DATA: tot(8) TYPE n.

DATA: cb-ot(5) TYPE c.

 

 

* {end}

 

 

*Tab

DATA: V_SEPARATOR TYPE X.

DATA: L_VALUE TYPE I VALUE 09.  "09=TAB  44=,  124=|

V_SEPARATOR = L_VALUE.

 

 

 

 

DATA: BEGIN OF wtype,

        lgann LIKE p0008-lga01,

        betnn LIKE p0008-bet01.

DATA: END OF wtype.

 

 

 

 

DATA: BEGIN OF record_2010 occurs 0,

        pernr_001(038),

        timr6_002(001),

        begda_003(010),

        endda_004(010),

        choic_005(035),

        begda_006(010),

        lgart_007(004),

        stdaz_008(009),

        anzhl_009(010),

        betrg_010(018),

        waers_011(005),

        stdaz_012(009).

DATA: END OF record_2010.

 

 

********************************

*Messages of call transaction

DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

 

 

*Batchinputdata of single transaction

DATA: BEGIN OF bdc_tab OCCURS 0.     "batch input table

        INCLUDE STRUCTURE bdcdata.     "bdc-batch data communication

DATA: END OF bdc_tab.

 

 

DATA: p_file LIKE rlgrap-filename.

DATA: p_log LIKE rlgrap-filename.

DATA: ot_records(5) TYPE c value '0'.

DATA: php_records(5) TYPE c value '0'.

DATA: sa_records(5) TYPE c value '0'.

 

 

*P_LINES for openind dataset

DATA: P_LINES TYPE c.

DATA: P_VALUE type c.

DATA: P_RETURN TYPE C.

 

 

DATA: P_FIELD_COUNT(2) TYPE C VALUE '23'.

 

 

*yap

DATA: P_STR_LENGTH(99) TYPE C.

 

 

DATA : L_COUNTER TYPE I.

DATA : L_FLAG(1) TYPE C .

CONSTANTS : TAB  TYPE X VALUE '09',

            CRET TYPE X VALUE '0D',

            FFD  TYPE X VALUE '0C',

            VT   TYPE X VALUE '0B',

            LFD  TYPE X VALUE '0A'.

 

 

CONSTANTS:

c_session(12) TYPE C VALUE 'OT_Microbus'.

 

 

************************************************************************

PARAMETERS:

***********

*Filename for ws_upload

p_file2  LIKE rlgrap-filename,

*p_type  LIKE rlgrap-filetype DEFAULT 'DAT',

p_log2 LIKE rlgrap-filename,

*session(12) TYPE c DEFAULT sy-uname,

cdismode DEFAULT 'N',

cupdmode DEFAULT 'S',

cb_manu AS CHECKBOX DEFAULT ''.

 

 

INITIALIZATION.

***************

*to populate source flat file name as parameter value.

 

 

  DATA: sysdat(8) TYPE c.

  WRITE sy-datum TO sysdat.

 

 

*{   REPLACE        ECDK900302                                        1

*\  CONCATENATE '\\Express88\sapmnt\'

*\              'interface\microbus2sap\'

*\              'OTMBUS_'

*\              sysdat

*\              '.txt'

*\              INTO intfpath.

"Changed by Syaifudin

IF sy-sysid = 'ECD'.

  "amended by flo 12/sep/2012

*  CONCATENATE '\\Express19\sapmnt\'

  CONCATENATE '\\express35.erlnet.myerl.local\SAPMNT\'

              'DEV\microbus2sap\'

              'OTMBUS_'

              sysdat

              '.txt'

              INTO intfpath.

else.

  "amended by flo 12/sep/2012

*  CONCATENATE '\\Express19\sapmnt\'

  CONCATENATE '\\express35.erlnet.myerl.local\SAPMNT\'

              'interface\microbus2sap\'

              'OTMBUS_'

              sysdat

              '.txt'

              INTO intfpath.

endif.

*}   REPLACE

  p_file2 = intfpath.

 

 

*{   REPLACE        ECDK900302                                        2

*\  CONCATENATE '\\Express88\sapmnt\'

*\              'interface\microbus2sap_log\'

*\              'OTMBUS_'

*\              sysdat

*\              '_log.txt'

*\              INTO intfpath2.

"Changed by Syaifudin

IF sy-sysid = 'ECD'.

  "amended by flo 12/sep/2012

*  CONCATENATE '\\Express19\sapmnt\'

  CONCATENATE '\\express35.erlnet.myerl.local\SAPMNT\'

              'interface\microbus2sap_log\'

              'OTMBUS_'

              sysdat

              '_log.txt'

              INTO intfpath2.

else.

  "amended by flo 12/sep/2012

*  CONCATENATE '\\Express19\sapmnt\'

  CONCATENATE '\\express35.erlnet.myerl.local\SAPMNT\'

              'interface\microbus2sap_log\'

              'OTMBUS_'

              sysdat

              '_log.txt'

              INTO intfpath2.

endif.

*}   REPLACE

  p_log2 = intfpath2.

 

 

 

 

************************************************************************

*13-01-2003 get path

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file2.

 

 

  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

       CHANGING

            file_name = p_file2.

 

 

 

 

START-OF-SELECTION.

*******************

  ph_pay = 'Y'.

  ph_callback = 'N'.

  IF NOT cb_manu IS INITIAL.

    p_file = p_file2.

    p_log = p_log2.

  ELSE.

    p_file = intfpath.

    p_log = intfpath2.

  ENDIF.

 

 

* Define ranges.

  PERFORM select_ranges.

 

 

* Read file from source

  PERFORM F_READ_TAB_DELIMITED_FILE TABLES file2

                               USING P_FIELD_COUNT P_file

                               CHANGING P_STR_LENGTH P_RETURN P_LINES.

 

 

* Add additional information into file2.

  PERFORM add_additional_data.

 

 

 

 

* Read file from source

*  PERFORM read_file_to_i_tab.

 

 

 

 

************************************************************************

END-OF-SELECTION.

*****************

* Check if flat file reading is OK

  IF readok = 'Y'.

 

 

*   Create session

    PERFORM create_session.

 

 

* Check for Public Holiday(s)

    PERFORM check_ph.

 

 

*   Calls program to update required fields for upload

    PERFORM batch_upload.

 

 

*   Close session

    PERFORM close_session.

 

 

*   Check if record_2010 or record_0015 for upload has data

    IF record_2010[] IS INITIAL.

*     text-200 : No data to upload.

      WRITE: / text-200.

      logtab-log = text-200. APPEND logtab. CLEAR logtab.

    ENDIF. "tab is initial

 

 

*   Auto submit to process session

    PERFORM AUTOSUBMIT_BDC USING 'OT_MICROBUS'.

 

 

  ENDIF. "readok = 'Y'

 

 

* print result of upload and error if present

  PERFORM write_file.

 

 

*  PERFORM create_log_file_in_server.

  PERFORM Logfile_DOWNLOAD TABLES   outputtab

                           USING    p_log log_type

                           CHANGING P_VALUE.

 

 

** save log file

*  PERFORM output_log.

 

 

************************************************************************

*To define ranges for wagetype mapping logics

************************************************

FORM select_ranges.

*******************

*for Employee Group range

* Employee group: 2-Permanent

  MOVE: 'I'  TO r_persg-sign,

        'EQ' TO r_persg-option,

        '2'  TO r_persg-low.

  APPEND r_persg.

* Employee group: 6-Temp (Payroll)

  MOVE '6' TO r_persg-low. APPEND r_persg.

* Employee group: 3-Contract-Payroll

  MOVE '3' TO r_persg-low. APPEND r_persg.

  CLEAR r_persg.

 

 

 

 

*for ERL GS office

* Employee subgroup: SUPP: OF4 - Office

  MOVE: 'I'  TO r_erlgso-sign,

        'EQ' TO r_erlgso-option,

        '14' TO r_erlgso-low.

  APPEND r_erlgso.

* Employee subgroup: SUPP: OF3 - Office

  MOVE '16' TO r_erlgso-low. APPEND r_erlgso.

* Employee subgroup: SUPP: OF2 - Office

  MOVE '18' TO r_erlgso-low. APPEND r_erlgso.

* Employee subgroup: SUPP: OF1 - Office

  MOVE '20' TO r_erlgso-low. APPEND r_erlgso.

* Employee subgroup: SUPP: OA1 - Office

  MOVE '22' TO r_erlgso-low. APPEND r_erlgso.

  CLEAR r_erlgso.

 

 

*  for ERL GS shift

* Employee subgroup: SUPP: OF4 - Shift

  MOVE: 'I'  TO r_erlgss-sign,

        'EQ' TO r_erlgss-option,

        '15' TO r_erlgss-low.

  APPEND r_erlgss.

* Employee subgroup: SUPP: OF3 - Shift

  MOVE '17' TO r_erlgss-low. APPEND r_erlgss.

* Employee subgroup: SUPP: OF2 - Shift

  MOVE '19' TO r_erlgss-low. APPEND r_erlgss.

* Employee subgroup: SUPP: OF1 - Shift

  MOVE '21' TO r_erlgss-low. APPEND r_erlgss.

* Employee subgroup: SUPP: OA1 - Shift

  MOVE '23' TO r_erlgss-low. APPEND r_erlgss.

  CLEAR r_erlgss.

 

 

*  for ERL Executive shift

* Employee subgroup: EXEC: VP1 - Shift

  MOVE: 'I'  TO r_erlexs-sign,

        'EQ' TO r_erlexs-option,

        '09' TO r_erlexs-low.

  APPEND r_erlexs.

* Employee subgroup: EXEC: SO2 - Shift

  MOVE '11' TO r_erlexs-low. APPEND r_erlexs.

* Employee subgroup: EXEC: SO1 - Shift

  MOVE '13' TO r_erlexs-low. APPEND r_erlexs.

  CLEAR r_erlexs.

 

 

*  for EMA GS office

* Employee subgroup: SUPP: GS4 - Office

  MOVE: 'I'  TO r_emasgso-sign,

        'EQ' TO r_emasgso-option,

        '35' TO r_emasgso-low.

  APPEND r_emasgso.

* Employee subgroup: SUPP: GS3 - Office

  MOVE '37' TO r_emasgso-low. APPEND r_emasgso.

* Employee subgroup: SUPP: GS2 - Office

  MOVE '39' TO r_emasgso-low. APPEND r_emasgso.

* Employee subgroup: SUPP: GS1 - Office

  MOVE '41' TO r_emasgso-low. APPEND r_emasgso.

  CLEAR r_emasgso.

 

 

*  for EMA GS shift

* Employee subgroup: SUPP: GS4 - Shift

  MOVE: 'I'  TO r_emasgss-sign,

        'EQ' TO r_emasgss-option,

        '36' TO r_emasgss-low.

  APPEND r_emasgss.

* Employee subgroup: SUPP: GS3 - Shift

  MOVE '38' TO r_emasgss-low. APPEND r_emasgss.

* Employee subgroup: SUPP: GS2 - Shift

  MOVE '40' TO r_emasgss-low. APPEND r_emasgss.

* Employee subgroup: SUPP: GS1 - Shift

  MOVE '42' TO r_emasgss-low. APPEND r_emasgss.

  CLEAR r_emasgss.

 

 

*  for EMAS Executive shift

* Employee subgroup: EXEC: EX3 - Shift

  MOVE: 'I'  TO r_emasexs-sign,

        'EQ' TO r_emasexs-option,

        '30' TO r_emasexs-low.

  APPEND r_emasexs.

* Employee subgroup: EXEC: EX2 - Shift

  MOVE '32' TO r_emasexs-low. APPEND r_emasexs.

* Employee subgroup: EXEC: EX1 - Shift

  MOVE '34' TO r_emasexs-low. APPEND r_emasexs.

 

 

  CLEAR r_emasexs.

 

 

 

 

ENDFORM. "select_ranges

 

 

 

 

************************************************************************

*READ FLAT FILE & ADD ADDITIONAL DATA

*Includes:

*1) read_file_to_i_tab - populate int. tab. with flat file values

*2) add_additional_data - populate required fields & assign wagetype

***********************************************************************

 

 

************************************************************************

* UPLOAD DATA

************************************************************************

* DATA: P_LINES TYPE c.

FORM F_READ_TAB_DELIMITED_FILE TABLES file2

                               USING P_FIELD_COUNT P_file

                               CHANGING P_STR_LENGTH P_RETURN P_LINES.

 

 

*DATA: L_MESSAGE(100).

 

 

  FIELD-SYMBOLS <FS> .

 

 

  CLEAR P_LINES .

 

 

*{   REPLACE        ECDK901215                                        1

*\  L_COUNTER = P_FIELD_COUNT - 1 .

*\  OPEN DATASET P_file FOR INPUT IN TEXT MODE.

*\  IF SY-SUBRC = 0.

*\    P_RETURN = '0' .

*\    DO .

*\      CLEAR P_STR_LENGTH .

*\      READ DATASET P_file INTO P_STR_LENGTH .

*\      IF SY-SUBRC <> 0.

*\        EXIT .

*\      ELSE .

*\        L_FLAG = ' ' .

*\        DO L_COUNTER TIMES .

*\          ASSIGN COMPONENT SY-INDEX OF STRUCTURE file2 TO <FS> .

*\          SPLIT P_STR_LENGTH AT TAB INTO <FS> P_STR_LENGTH .

*\        ENDDO .

*\      ENDIF .

*\      ADD 1 TO L_COUNTER .

*\      ASSIGN COMPONENT L_COUNTER OF STRUCTURE file2 TO <FS> .

*\*          Insert MUC0899

*\      SPLIT P_STR_LENGTH AT TAB  INTO <FS> P_STR_LENGTH .

*\      SPLIT <FS>         AT CRET INTO <FS> P_STR_LENGTH .

*\      SPLIT <FS>         AT FFD  INTO <FS> P_STR_LENGTH .

*\      SPLIT <FS>         AT VT   INTO <FS> P_STR_LENGTH .

*\      SPLIT <FS>         AT LFD  INTO <FS> P_STR_LENGTH .

*\*          REmove MUC0899

*\*          <FS> = P_STR_LENGTH .

*\      APPEND file2 .

*\      SUBTRACT 1 FROM L_COUNTER .

*\*          ENDIF .

*\      CLEAR file2 .

*\    ENDDO.

*\*   Assign read ok to 'Y' (Yes)

*\    readok = 'Y'.

*\  ELSE .

*\*       P_MESSAGE = L_MESSAGE. "Pass only if fails

*\*      message e016(ds) with 'Error opening FILE' P_FNAME .

*\    P_RETURN = '1' .

*\  ENDIF .

 

 

L_COUNTER = P_FIELD_COUNT - 1 .

 

 

"manual upload where flatfile is not uploading from server express35

IF cb_manu EQ 'X' AND p_file2 NE intfpath.

  DATA: tmp_file TYPE string.

  tmp_file = p_file2.

 

 

  CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

      FILENAME                      = tmp_file

      FILETYPE                      = 'ASC'

*      HAS_FIELD_SEPARATOR           = 'X'

    TABLES

      DATA_TAB                      = tmp_file2

    EXCEPTIONS

      FILE_OPEN_ERROR               = 1

      FILE_READ_ERROR               = 2

      NO_BATCH                      = 3

      GUI_REFUSE_FILETRANSFER       = 4

      INVALID_TYPE                  = 5

      NO_AUTHORITY                  = 6

      UNKNOWN_ERROR                 = 7

      BAD_DATA_FORMAT               = 8

      HEADER_NOT_ALLOWED            = 9

      SEPARATOR_NOT_ALLOWED         = 10

      HEADER_TOO_LONG               = 11

      UNKNOWN_DP_ERROR              = 12

      ACCESS_DENIED                 = 13

      DP_OUT_OF_MEMORY              = 14

      DISK_FULL                     = 15

      DP_TIMEOUT                    = 16

      OTHERS                        = 17.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ELSE.

    P_RETURN = '0'.

 

 

    LOOP AT tmp_file2.

      L_FLAG = ' ' .

      DO L_COUNTER TIMES .

        ASSIGN COMPONENT SY-INDEX OF STRUCTURE file2 TO <FS> .

        SPLIT tmp_file2-P_STR_LENGTH AT TAB INTO <FS> tmp_file2-P_STR_LENGTH.

      ENDDO .

      ADD 1 TO L_COUNTER .

      ASSIGN COMPONENT L_COUNTER OF STRUCTURE file2 TO <FS> .

      SPLIT TMP_FILE2-P_STR_LENGTH AT TAB  INTO <FS> TMP_FILE2-P_STR_LENGTH .

      SPLIT <FS>         AT CRET INTO <FS> TMP_FILE2-P_STR_LENGTH .

      SPLIT <FS>         AT FFD  INTO <FS> TMP_FILE2-P_STR_LENGTH .

      SPLIT <FS>         AT VT   INTO <FS> TMP_FILE2-P_STR_LENGTH .

      SPLIT <FS>         AT LFD  INTO <FS> TMP_FILE2-P_STR_LENGTH .

 

 

      APPEND file2 .

      SUBTRACT 1 FROM L_COUNTER .

 

 

      CLEAR file2 .

    ENDLOOP.

*   Assign read ok to 'Y' (Yes)

    readok = 'Y'.

  ENDIF.

ELSE.

  OPEN DATASET P_file FOR INPUT IN TEXT MODE.

  IF SY-SUBRC = 0.

    P_RETURN = '0' .

    DO .

      CLEAR P_STR_LENGTH .

      READ DATASET P_file INTO P_STR_LENGTH .

      IF SY-SUBRC <> 0.

        EXIT .

      ELSE .

        L_FLAG = ' ' .

        DO L_COUNTER TIMES .

          ASSIGN COMPONENT SY-INDEX OF STRUCTURE file2 TO <FS> .

          SPLIT P_STR_LENGTH AT TAB INTO <FS> P_STR_LENGTH .

        ENDDO .

      ENDIF .

      ADD 1 TO L_COUNTER .

      ASSIGN COMPONENT L_COUNTER OF STRUCTURE file2 TO <FS> .

*          Insert MUC0899

      SPLIT P_STR_LENGTH AT TAB  INTO <FS> P_STR_LENGTH .

      SPLIT <FS>         AT CRET INTO <FS> P_STR_LENGTH .

      SPLIT <FS>         AT FFD  INTO <FS> P_STR_LENGTH .

      SPLIT <FS>         AT VT   INTO <FS> P_STR_LENGTH .

      SPLIT <FS>         AT LFD  INTO <FS> P_STR_LENGTH .

 

 

      APPEND file2 .

      SUBTRACT 1 FROM L_COUNTER .

 

 

      CLEAR file2 .

    ENDDO.

*   Assign read ok to 'Y' (Yes)

    readok = 'Y'.

  ELSE .

*       P_MESSAGE = L_MESSAGE. "Pass only if fails

*      message e016(ds) with 'Error opening FILE' P_FNAME .

    P_RETURN = '1' .

  ENDIF .

ENDIF.

 

 

*}   REPLACE

 

 

  DESCRIBE TABLE file2 LINES P_LINES .

 

 

ENDFORM.

 

 

 

 

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

*       FORM read_file_to_i_tab                                       *

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

*       ........                                                      *

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

FORM read_file_to_i_tab.

************************

* text-300 : Perform read flat file from :

  WRITE: / text-300, p_file.

  CONCATENATE text-300 p_file INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

  CALL FUNCTION 'WS_UPLOAD'

       EXPORTING

            filename                = p_file

            filetype                = 'DAT'

       TABLES

            data_tab                = file2  "file to be transfered to

       EXCEPTIONS

            conversion_error        = 1

            file_open_error         = 2

            file_read_error         = 3

            invalid_type            = 4

            no_batch                = 5

            unknown_error           = 6

            invalid_table_width     = 7

            gui_refuse_filetransfer = 8

            customer_error          = 9

            others                  = 10.

 

 

  IF sy-subrc <> 0.

*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

 

 

*   Write to file flat file read error.

    CASE sy-subrc.

      WHEN 01.

        WRITE 'WS_UPLOAD error 01 : conversion_error'.

        logtab-log = 'WS_UPLOAD error 01 : conversion_error'.

        APPEND logtab. CLEAR logtab.

      WHEN 02.

        WRITE 'WS_UPLOAD error 02 : file_open_error'.

        logtab-log = 'WS_UPLOAD error 02 : file_open_error'.

        APPEND logtab. CLEAR logtab.

      WHEN 03.

        WRITE 'WS_UPLOAD error 03 : file_read_error'.

        logtab-log = 'WS_UPLOAD error 03 : file_read_error'.

        APPEND logtab. CLEAR logtab.

      WHEN 04.

        WRITE 'WS_UPLOAD error 04 : invalid_type'.

        logtab-log = 'WS_UPLOAD error 04 : invalid_type'.

        APPEND logtab. CLEAR logtab.

      WHEN 05.

        WRITE 'WS_UPLOAD error 05 : no_batch '.

        logtab-log = 'WS_UPLOAD error 05 : no_batch '.

        APPEND logtab. CLEAR logtab.

      WHEN 06.

        WRITE 'WS_UPLOAD error 06 : unknown_error'.

        logtab-log = 'WS_UPLOAD error 06 : unknown_error'.

        APPEND logtab. CLEAR logtab.

      WHEN 07.

        WRITE 'WS_UPLOAD error 07 : invalid_table_width'.

        logtab-log = 'WS_UPLOAD error 07 : invalid_table_width'.

        APPEND logtab. CLEAR logtab.

      WHEN 08.

        WRITE 'WS_UPLOAD error 08 : gui_refuse_filetransfer'.

        logtab-log = 'WS_UPLOAD error 08 : gui_refuse_filetransfer'.

        APPEND logtab. CLEAR logtab.

      WHEN 09.

        WRITE 'WS_UPLOAD error 09 : customer_error'.

        logtab-log = 'WS_UPLOAD error 09 : customer_error'.

        APPEND logtab. CLEAR logtab.

      WHEN 10.

        WRITE 'WS_UPLOAD error 10 : others'.

        logtab-log = 'WS_UPLOAD error 10 : others'.

        APPEND logtab. CLEAR logtab.

    ENDCASE.

 

 

  ELSE.

 

 

*   Assign read ok to 'Y' (Yes)

    readok = 'Y'.

 

 

*   text-100 : File read successfully :

    WRITE: / text-100, p_file LEFT-JUSTIFIED.

    CONCATENATE text-100 p_file ' .' INTO logtab-log.

    APPEND logtab. CLEAR logtab.

 

 

*   Populate required fields & assign wagetype

 

 

*   text-301 : Perform allocate wagetype.

    WRITE: / text-301.

    logtab-log = text-301. APPEND logtab. CLEAR logtab.

 

 

    PERFORM add_additional_data.

 

 

 

 

*   text-302 : End - Flat file read & wagetype allocation.

    WRITE: / text-302.

    logtab-log = text-302. APPEND logtab. CLEAR logtab.

 

 

  ENDIF. "sy-subrc <> 0.

 

 

ENDFORM. "read_file_to_i_tab

 

 

************************************************************************

FORM add_additional_data.

*************************

 

 

************************************************************************

  LOOP AT file2.

 

 

    CLEAR file.

 

 

 

 

* Change scheduled duty begin time

    CONCATENATE file2-sdbtm+0(2)

                file2-sdbtm+3(2)

                '00'

               INTO file-sdbtm.

 

 

* Change scheduled duty end time

    CONCATENATE file2-sdetm+0(2)

                file2-sdetm+3(2)

                '00'

               INTO file-sdetm.

 

 

* Change actual duty begin time

    CONCATENATE file2-adetm+0(2)

                file2-adetm+3(2)

                '00'

               INTO file-adetm.

 

 

* Change actual duty end time

    CONCATENATE file2-adbtm+0(2)

                file2-adbtm+3(2)

                '00'

               INTO file-adbtm.

 

 

* Change actual duty hours

    file2-acdhr_cal = file2-acdhr+3(2) / 60.

*    KAF Start on 20/1/2004

    if file2-acdhr_cal = '   0'.

      file2-acdhr_cal = '0.00'.

    endif.

*    KAF End on 20/1/2004

    IF file2-acdhr_cal+2(1) = '.'.

      temp = '0.'.

      temp1 = file2-acdhr_cal+3(1).

      temp2 = '0'.

      CONCATENATE temp temp1 temp2 INTO file2-acdhr_cal.

    ENDIF.

 

 

* {start} No#002

    If file2-acdhr_cal+4(1) IS INITIAL.

* {end}

      CONCATENATE file2-acdhr+0(2)

                  '.'

*                  file2-acdhr_cal+3(2) "KAF Remove on 20/1/2004

                  file2-acdhr_cal+2(2)  "KAF Add on 20/1/2004

                  INTO file-acdhr.

* {start} No#002

    else.

      CONCATENATE file2-acdhr+0(2)

                  '.'

                  file2-acdhr_cal+2(2)

                  INTO file-acdhr.

 

 

    endif.

* {end}

* Change ot hours

    file2-othrs_cal = file2-othrs+3(2) / 60.

*    KAF Start on 20/1/2004

    if file2-othrs_cal = '   0'.

      file2-othrs_cal = '0.00'.

    endif.

*    KAF End on 20/1/2004

    IF file2-othrs_cal+2(1) = '.'.

      temp = '0.'.

      temp1 = file2-othrs_cal+3(1).

      temp2 = '0'.

      CONCATENATE temp temp1 temp2 INTO file2-othrs_cal.

    ENDIF.

 

 

* {start} No#002

    If file2-othrs_cal+4(1) IS INITIAL.

* {end}

      CONCATENATE file2-othrs+0(2)

                  '.'

*                  file2-othrs_cal+3(2)  "KAF Remove on 20/1/2004

                  file2-othrs_cal+2(2)   "KAF Add on 20/1/2004

                  INTO file-othrs.

* {start} NO#002

    else.

      CONCATENATE file2-othrs+0(2)

                  '.'

                  file2-othrs_cal+2(2)

                  INTO file-othrs.

    endif.

* {end}

 

 

 

 

* Move other value into file intenal table

    MOVE: file2-pernr to file-pernr,

          file2-mbwtype to file-mbwtype,

          file2-scact to file-scact,

          file2-acact to file-acact,

          file2-otleaveindi to file-otleaveindi,

          file2-pdate to file-pdate,

          file2-otdat to file-otdat,

*  yap {start}

          file2-extra1 to file-extra1,

          file2-extra2 to file-extra2,

          file2-extra3 to file-extra3,

          file2-extra4 to file-extra4.

*  yap {end}

 

 

    APPEND file.

    CLEAR: file2,

          file.

 

 

  ENDLOOP.

**********************************************************koonhon*******

 

 

  LOOP AT file.

*   Retrieve total salary

    CLEAR pa0008.

    SELECT SINGLE * FROM pa0008 " into corresponding fields of pa0008

    WHERE pernr = file-pernr

    AND   endda = '99991231'.

    DO 20 TIMES

    VARYING wtype

    FROM pa0008-lga01

    NEXT pa0008-lga02.

      IF wtype-lgann = 1000

      OR wtype-lgann = 1003

      OR wtype-lgann = 1004.

        ADD wtype-betnn TO file-salary.

      ENDIF.

      IF wtype IS INITIAL.

        EXIT.

      ENDIF.

    ENDDO.

 

 

*   Retrieve personnel status

    CLEAR: pa0000-stat2.

    SELECT SINGLE stat2 FROM pa0000

    INTO (file-stat2)

    WHERE pernr = file-pernr AND endda = '99991231'.

 

 

*   Retrieve personnel data

    CLEAR: pa0001-werks, pa0001-persg, pa0001-persk.

    SELECT SINGLE werks persg persk FROM pa0001

    INTO (file-werks,file-persg,file-persk)

    WHERE pernr = file-pernr AND endda = '99991231'.

 

 

*   Retrieve employee subgroup for substitutes

    CLEAR: hrp1001.

    SELECT SINGLE sobid FROM hrp1001 INTO hrp1001-sobid

    WHERE otype = 'P'

    AND   objid = pernr-pernr

    AND   plvar = '01'

    AND   istat = 1

    AND   subty = 'B010'

    AND   sclas = 'S'

    AND   ENDDA = '99991231'.

 

 

    CLEAR: hrp1013.

    SELECT SINGLE persg persk FROM hrp1013

    INTO (hrp1013-persg,hrp1013-persk)

    WHERE plvar = '01'

    AND   otype = 'S'

    AND   objid = hrp1001-sobid

    AND   istat = 1

    AND   endda = '99991231'.

 

 

    IF NOT hrp1013-persg IS INITIAL.

      file-persg = hrp1013-persg.

    ELSEIF NOT hrp1013-persk IS INITIAL.

      file-persk = hrp1013-persk.

    ENDIF.

 

 

 

 

*   Allocate wagetype

*   Ensure employee to be active: stat2 = 3.

*     employee group (Permanent): persg = 2

    IF file-stat2 = '3' AND file-persg IN r_persg.

 

 

      start_tm = '      '.

      end_tm = '      '.

      CLEAR: start_tm.

      CLEAR: end_tm.

 

 

      IF file-sdbtm = file-adbtm AND       " 1st condition start time

         file-sdetm = file-adetm.

        start_tm = file-sdbtm.

      elseif

             file-sdbtm <> file-adbtm AND  " 2nd condition start time

             file-sdetm <> file-adetm.

        IF file-sdbtm = 0 AND  "5th condition start time for callback

           file-sdetm = 0.

          start_tm = file-adbtm.

        elseif

*          Add-on NOV {start}

           file-sdbtm <> 0 AND

           file-sdetm <> 0.

*          Add-on NOV {end}

          start_tm = file-adbtm.

        endif.

      elseif

             file-sdbtm = file-adbtm AND    " 3rd condition start time

             file-sdetm <> file-adetm.

        start_tm = file-adbtm.

      elseif

             file-sdbtm <> file-adbtm AND   " 4th condition start time

             file-sdetm = file-adetm.

        IF file-othrs > 0.

          if file-othrs >= 10.

            start_tm = file-sdbtm.

          elseif file-othrs < 10.

            start_tm = file-sdbtm.

          endif.

        elseif file-othrs = 0.

          start_tm = file-sdbtm.

        endif.

 

 

      ENDIF.

 

 

      file-finalstart = start_tm.

* END for Start time

 

 

 

 

* Start for end time.

      IF file-sdbtm = file-adbtm AND            " 1st condition end time

         file-sdetm = file-adetm.

        end_tm = file-sdetm.

      elseif

         file-sdbtm <> file-adbtm AND       " 2nd condition end time

         file-sdetm <> file-adetm.

        If file-sdbtm = 0 AND    "5th condition end time for callback

           file-sdetm = 0.

          IF file-othrs > 0.

            if file-othrs >= 10.

              cal_othr = file-othrs+2(3) * 60.

              if cal_othr = 0.

                CONCATENATE file-othrs+0(2) cal_othr '0' '00' into

join_ot.

              elseif cal_othr <> 0.

*             add-on NOV {end}

                CONCATENATE file-othrs+0(2) cal_othr '00' into join_ot.

*             add-on NOV {start}

              endif.

*             add-on NOV {end}

*******************************************

            elseif file-othrs < 10.

**              elseif cb-ot < 10.

              cal_othr = file-othrs+2(3) * 60.

*             add-on NOV {start}

              if cal_othr = 0.

                CONCATENATE '0' file-othrs+1(1) cal_othr '0' '00' into

join_ot.

              elseif cal_othr <> 0.

*             add-on NOV {end}

                CONCATENATE '0' file-othrs+1(1) cal_othr '00' into

join_ot.

*             add-on NOV {start}

              endif.

*             add-on NOV {end}

            endif.

            cal_ot_sys = join_ot.

            adetm_int = file-adetm.

            minus_ot = adetm_int - cal_ot_sys.

            CONCATENATE minus_ot+0(2) minus_ot+2(2) minus_ot+4(2) into

end_tm.

          elseif file-othrs = 0.

            end_tm = file-adetm.

          ENDIF.                           " end of callback

 

 

 

 

        ELSEIF

            file-sdbtm <> 0 AND

            file-sdetm <> 0.

 

 

          IF file-othrs > 0.

            if file-othrs >= 10.

              end_tm = file-adetm.

            elseif file-othrs < 10.

              end_tm = file-adetm.

            endif.

          elseif file-othrs = 0.

            end_tm = file-adetm.

          ENDIF.

        ENDIF.

      elseif

           file-sdbtm = file-adbtm AND          " 3rd condition end time

             file-sdetm <> file-adetm.

        IF file-othrs > 0.

          if file-othrs >= 10.

            cal_othr = file-othrs+2(3) * 60.

*             add-on NOV {start}

            if cal_othr = 0.

              CONCATENATE file-othrs+0(2) cal_othr '0' '00' into

join_ot.

            elseif cal_othr <> 0.

*             add-on NOV {end}

 

 

              CONCATENATE file-othrs+0(2) cal_othr '00' into join_ot.

*             add-on NOV {start}

            endif.

*             add-on NOV {end}

 

 

          elseif file-othrs < 10.

            cal_othr = file-othrs+2(3) * 60.

*             add-on NOV {start}

            if cal_othr = 0.

              CONCATENATE '0' file-othrs+1(1) cal_othr '0' '00' into

join_ot.

            elseif cal_othr <> 0.

*             add-on NOV {end}

 

 

              CONCATENATE '0' file-othrs+1(1) cal_othr '00' into

join_ot.

*             add-on NOV {start}

            endif.

*             add-on NOV {end}

          endif.

          cal_ot_sys = join_ot.

          adetm_int = file-adetm.

          minus_ot = adetm_int - cal_ot_sys.

          CONCATENATE minus_ot+0(2) minus_ot+2(2) minus_ot+4(2) into

end_tm.

        elseif file-othrs = 0.

          end_tm = file-adetm.

        ENDIF.

      elseif

           file-sdbtm <> file-adbtm AND         " 4th condition end time

             file-sdetm = file-adetm.

        end_tm = file-adetm.

 

 

      ENDIF.

 

 

      file-finalend = end_tm.

 

 

* yap {end}

 

 

*   Allocate wagetype

 

 

*     Populate 'previous actual activity' and 'next actual activity'

      PERFORM pop_prev_n_next_acact USING file-otdat file-pernr.

 

 

*     Populate shift allowance indicator for scheduled shift begin time

      PERFORM get_allw_shift_indi USING    file-otdat

                                            file-finalstart

                                  CHANGING file-sdbtmindi.

 

 

*     Populate shift allowance indicator for scheduled shift end time

      PERFORM get_allw_shift_indi USING    file-otdat

                                            file-finalend  "yap

                                  CHANGING file-sdetmindi.

 

 

*-------------------------------- OT (begin) ---------------------------

*     OT hours > 0

      IF file-othrs > 0.

 

 

*       For erl and emas general support

        IF file-persk IN r_erlgss OR file-persk IN r_emasgss.

 

 

*#########microbus wagetype = 1 (Normal day)

          IF file-mbwtype = 1.

*           schedule/actual activity = 4-Duty, 4-Duty

            IF     file-scact   = 4 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

*           schedule/actual activity = 2-Rest, 4-Duty

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

*                   {start} SWAP NO#002

*          file-extra3 <> 'PLAN' AND  # remarks by KAH on 2/12/2003

                  file-extra3 = 'CBACKOR' AND "KAH add

*                   {end} SWAP

                    file-othrs   <= 4.

              file-wtype = 6001. file-status = '-'.

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

*                   {start} SWAP

*          file-extra3 <> 'PLAN' AND  # remarks by KAH on 2/12/2003

                  file-extra3 = 'CBACKOR' AND "KAH add

*                   {end} SWAP

                   file-othrs   > 4 AND

                   file-othrs   <= 8.

              file-wtype = 6002. file-status = '-'.

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

*                   {start} SWAP

*          file-extra3 <> 'PLAN' AND  # remarks by KAH on 2/12/2003

                  file-extra3 = 'CBACKOR' AND "KAH add

*                   {end} SWAP

                   file-othrs   > 8.

              file-wtype = 6002. file-status = '-'.

************************************************************************

*              file-wtype2 = 6003.

*ADD_ON NOV 6003 {start} yap

              file-wtype2 = 6003. file-status2 = '-'.

*ADD_ON NOV 6003 {end} yap

**************************************************koonhon02052002*******

*******SWAP  {start}

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

*              file-extra3 = 'PLAN' AND  # remarks by KAH on 2/12/2003

                     file-extra3 <> 'CBACKOR' AND     "KAH add

                    file-othrs   > 0.

              file-wtype = 6000. file-status = '-'.

*******SWAP  {end}

 

 

*           schedule/actual activity = 1-Off, 4-Duty

            ELSEIF file-scact   = 1 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

*           schedule/actual activity = 3-Standby, 4-Duty

            ELSEIF file-scact   = 3 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

            ELSE.

* text-001:

* Error 1 : No valid combination found for '1-Normal Day' wagetype

*           (ERL/EMAS GS).

              file-status = text-001.

            ENDIF. "microbus wagetype = 1 (Normal Day)

 

 

 

 

*#########microbus wagetype = 4 (Special Public Holiday)

          ELSEIF file-mbwtype = 4.

*         schedule/actual activity = 4-Duty, 4-Duty

            IF     file-scact   = 4 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

*           schedule/actual activity = 2-Rest, 4-Duty

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

                   file-othrs   <= 4.

              file-wtype = 6001. file-status = '-'.

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

                   file-othrs   > 4 AND

                   file-othrs   <= 8.

              file-wtype = 6002. file-status = '-'.

            ELSEIF file-scact   = 2 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ) AND

                   file-othrs   > 8.

              file-wtype = 6002. file-status = '-'.

************************************************************************

*              file-wtype2 = 6003.

*ADD_ON NOV 6003 {start} yap

              file-wtype2 = 6003. file-status2 = '-'.

*ADD_ON NOV 6003 {end} yap

 

 

***************************************************koonhon02052002******

*           schedule/actual activity = 1-Off, 4-Duty

            ELSEIF file-scact   = 1 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

*           schedule/actual activity = 3-Standby, 4-Duty

            ELSEIF file-scact   = 3 AND

                   ( file-acact   = 4 OR

                     file-acact   = 3 ).

              file-wtype = 6000. file-status = '-'.

            ELSE.

* text-002:

* Error 2 : No valid combination found for '4-Public Holiday with Normal

*           Rate' wagetype (ERL/EMAS GS).

              file-status = text-002.

            ENDIF. "mbus wtype = 4 (Special Public Holiday)

 

 

 

 

*#########microbus wagetype = 2 (Public holiday)

          ELSEIF file-mbwtype = 2.

*           Scheduled activity: 1(Off), 2(Rest)

*           Actual activity   : 3(Standby), 4(Duty)

            IF ( file-acact = 3 OR file-acact = 4 ) AND

               ( file-scact = 1 OR file-scact = 2 ).

*              KAF change from 6000 to 6005 on 29/1/2004

              file-wtype = 6005. file-status = '-'.

 

 

*              KAF Add on 19/02/2004

              IF file-scact = 2 AND file-extra3 = 'CBACKOR'.

                file-wtype = 6002. file-status = '-'.

              ENDIF.

              IF file-scact = 1 AND file-extra3 = 'CBACKOR'.

                file-wtype = 6000. file-status = '-'.

              ENDIF.

*              KAF End

 

 

 

 

 

 

*           Scheduled activity: 3(Standby), 4(Duty)

*           Actual activity   : 3(Standby), 4(Duty)

            ELSEIF ( file-acact = 3 OR file-acact = 4 ) AND

                   ( file-scact = 3 OR file-scact = 4 ).

*             Previous/Next actual activity = 6(Unjustified Leave)

              IF file-prevacact = 6 OR file-nextacact = 6.

                file-wtype = 6000. file-status = '-'.

              ELSE.

                file-wtype = 6005. file-status = '-'.

 

 

 

 

              ENDIF. "prev/next acact = 6 (unjustified leave)

            ELSE.

* text-003:

* Error 3 : No valid combination found for '2-Public Holiday' wagetype

*           (ERL/EMAS GS).

              file-status = text-003.

            ENDIF. "microbus wagetype = 2 (Public holiday)

 

 

 

 

*#######microbus wagetype = 3 (Day After Public Holiday)

          ELSEIF file-mbwtype = 3.

 

 

*           Scheduled activity: 3(Standby), 4(Duty)

*           Actual activity   : 3(Standby), 4(Duty)

            IF ( file-acact = 4 OR file-acact = 3 ) AND

               ( file-scact = 4 OR file-scact = 3 ).

              IF file-prevacact = 1 OR file-prevacact = 2.

*                (emp'ee did not work on PH)

                file-wtype = 6005. file-status = '-'.

                IF file-othrs > 0.

                  file-wtype2 = 6005.

                ENDIF. "file-othrs

              ELSE. "file-prevacact NE 1 or 2 (emp'ee worked on PH)

                file-wtype = 6000. file-status = '-'.

              ENDIF. "file-prevacact = 1 OR 2

 

 

*           Scheduled activity: 1(Off)

*           Actual activity   : 3(Standby), 4(Duty)

            ELSEIF ( file-acact = 4 OR file-acact = 3 ) AND

                   file-scact = 1.

              IF file-prevacact = 1 OR file-prevacact = 2.

*               (emp'ee did not work on PH)

                file-wtype = 6000. file-status = '-'.

 

 

 

 

              ELSE. "file-prevacact NE 1 OR 2 (emp'ee worked on PH)

                file-wtype = 6000. file-status = '-'.

 

 

 

 

              ENDIF. "file-prevacact = 1 OR 2

 

 

*           Scheduled activity: 2(Rest)

*           Actual activity   : 3(Standby), 4(Duty)

            ELSEIF ( file-acact = 4 OR file-acact = 3 ) AND

                   file-scact = 2.

              IF file-prevacact = 1 OR file-prevacact = 2.

*               (emp'ee did not work on PH)

                file-wtype = 6000. file-status = '-'.

*                  KAF Add on 29/01/2004

              ELSEIF file-prevacact = 4 AND file-extra3 <> 'CBACKOR'.

                file-wtype = 6000. file-status = '-'.

*                  KAF End 29/01/2004

 

 

 

 

 

 

              ELSE. "file-prevacact NE

                IF file-othrs   <= 4.

                  file-wtype = 6001. file-status = '-'.

                ELSEIF file-othrs   > 4 AND

                       file-othrs   <= 8.

                  file-wtype = 6002. file-status = '-'.

                ELSEIF file-othrs   > 8.

                  file-wtype = 6002. file-status = '-'.

************************************************************************

*              file-wtype2 = 6003.

*ADD_ON NOV 6003 {start} yap

*                 file-wtype2 = 6003. file-status2 = '-'.

*ADD_ON NOV 6003 {end} yap

 

 

***************************************************koonhon05022002******

                ENDIF.

              ENDIF. "file-othrs = 2

 

 

            ELSE.

 

 

* text-004:

* Error 4 : No valid combination found for '3-Day After

*           Public Holiday' wagetype (ERL/EMAS GS).

              file-status = text-004.

            ENDIF. "mbus wtype=3(Day After Public Holiday)

 

 

          ELSE. "not wbwtype 1,2,3,4

* text-005:

* Error 5 : Microbus wagetype invalid (NOT 1,2,3,or 4) for ERL/EMAS GS.

            file-status = text-005.

          ENDIF. "file-wbwtype=1

 

 

 

 

*       For erl and emas executive

        ELSEIF file-persk IN r_erlexs OR file-persk IN r_emasexs.

 

 

*         microbus wagetype = 1 (Normal day),

*                             3 (Day After Public Holiday)

          IF file-mbwtype = 1 OR file-mbwtype = 3.

 

 

*           schedule activity : 1-Off, 2-Rest

*           actual activity   : 4-Duty

            IF ( file-acact = '4' OR file-acact = '3' ) AND

               ( file-scact = '1' OR

                 file-scact = '2' ) AND

               file-othrs >= '1'.

              file-wtype = '6017'. file-status = '-'.

 

 

*           schedule activity : 3-Standby, 4-Duty, 5-Leave

*           actual activity   : 4-Duty

            ELSEIF ( file-acact = '4' OR file-acact = '3' ) AND

                   ( file-scact = '3' OR

                     file-scact = '4' OR

                     file-scact = '5' ) AND

                   file-othrs >= '1'.

              file-wtype = '6016'. file-status = '-'.

            ELSE. "not file-mbwtype = 1/3

*   text-006:

*  Error 6 : Actual activity for '1-Normal Day' OR '3-Day

*            After Public Holiday' is not '4-Duty'. Else,

*            insufficient OT hours (<1 hour) (ERL/EMAS EXEC).

              file-status = text-006.

            ENDIF.

 

 

 

 

 

 

****************  PENDING INDICATOR ************************************

*         microbus wagetype = 2 (Public holiday)

          ELSEIF file-mbwtype = 2.

*           schedule activity = 1-Off, 2-Rest, 3-Standby, 4-Duty

*           actual activity = 4-Duty

            IF ( file-acact = '4' OR file-acact = '3' ) AND

               ( file-scact = '1' OR

                 file-scact = '2' OR

                 file-scact = '3' OR

                 file-scact = '4' ).

*             OT or Leave indicator: 0-Not relevant, 1-OT, 2-Leave

              IF file-otleaveindi = '1'.

                file-wtype = 6017. file-status = '-'.

 

 

************************ADD leave logic************************

              ELSEIF file-otleaveindi = '2'.

                file-status = 'To be replaced by leave'.

              ENDIF.

 

 

************************ADD leave logic************************

            ELSE. "not file-mbwtype = 2

*   text-007:

*   Error 7 : Actual activity for '2-Public holiday' is not

*             '4-Duty' (ERL/EMAS EXEC).

              file-status = text-007.

            ENDIF.

 

 

          ENDIF. "file-mbwtype = 1/3, file-mbwtype = 2

 

 

 

 

        ELSE. "not in erl/emas gss/exs

* text-008:

* Error 8 : Employee not in ERL/EMAS general support/exec shift range.

          file-status = text-008.

        ENDIF. "erl/emas gss/exs

      ELSE. "file-othrs <= 0

* text-009: Error 9 : Invalid OT hours (Less than or equals to 0).

        file-status = text-009.

      ENDIF. "file-othrs > 0

 

 

*--- OT (end) ---

 

 

* ----------------------------Public Holiday Pay (begin)----------------

*     Actual duty hours > 0

*      IF file-acdhr > 0 AND file-acdhr <= 8.

*     Change from 9. In future may be not need. (Teoh)

*      IF file-acdhr > 0 AND file-acdhr <= 19.

 

 

*       microbus wagetype = 2 (Public holiday)

*       schedule activity = 3-Standby, 4-Duty

*       actual activity   = 4-Duty

      IF   file-mbwtype = 2.

 

 

*             On leave on PH

        IF ( file-acact  = 5 ).

          ph_pay = 'Y'.

 

 

*             Working on PH

        ELSEIF ( file-acact  = 4 OR file-acact = 3 ) AND

           ( file-persk IN r_erlgss OR file-persk IN r_emasgss ) AND

           ( file-scact = 3 OR file-scact = 4 ).

 

 

          file-phpwtype = 6006. file-phpstat = '-'.

          ph_pay = 'Y'.

 

 

*             Swap Duty

        ELSEIF ( file-scact = 1 OR file-scact = 2 ) AND

               ( file-acact = 3 OR file-acact = 4 ) AND

               ( file-extra3 = 'PTausch' OR

                 file-extra3 = 'DTausch' OR

                 file-extra3 = 'PLAN' ).

 

 

          file-phpwtype = 6006. file-phpstat = '-'.

          ph_pay = 'Y'.

 

 

*             Call back on PH

        ELSEIF ( file-scact = 1 OR file-scact = 2 ) AND

               ( file-acact = 3 OR file-acact = 4 ).

 

 

          ph_callback = 'Y'.

          ph_pay = 'N'.

 

 

        ELSE.

 

 

*             OFF / REST on PH

          ph_pay = 'N'.

 

 

        ENDIF.

 

 

*       microbus wagetype = 3 (Day After Public Holiday)

*       actual activity   = 4-Duty

*       previous actual activity = 2-Rest

      ELSEIF file-mbwtype = 3.

 

 

*             On leave on DAPH

        IF ( file-acact  = 5 ).

          ph_pay = 'Y'.

 

 

* KAF remarks to avoid double pay for PH 26/09/2003

**             Working on DAPH

*        ELSEIF  ( file-acact = 4 OR file-acact = 3 ) AND

*            ( file-persk IN r_erlgss OR file-persk IN r_emasgss ) AND

*            ( ( file-prevacact = 2 OR file-prevacact = 1 ) OR

*              ( ph_callback = 'Y') ).

*

*          file-phpwtype = 6004. file-phpstat = '-'.

*          ph_pay = 'Y'.

*          ph_callback = 'N'.

* KAF end remarks

 

 

        ENDIF.

 

 

*       microbus wagetype = 1 (Normal Day)

*       actual activity   = 4-Duty

*       previous actual activity = 2-Rest

      ELSEIF file-mbwtype = 1.

*            ON Leave on after PH(2) & DAPH(3)

 

 

* KAF remarks to avoid double pay for PH 30/09/2003

*        IF ( ph_pay = 'N' AND file-acact  = 5 ).

*          ph_pay = 'Y'.

*

*        ELSEIF  ph_pay = 'N' AND

*            ( file-acact  = 4 OR file-acact = 3 ).

*

*          file-phpwtype = 6004. file-phpstat = '-'.

*          ph_pay = 'Y'.

*        ENDIF.

* KAF end remarks

 

 

      ELSE. "main php logic

 

 

* text-010:

* Error 10 : ERL/EMAS GSS/Exec not on 4-Duty from scheduled

*            3-standby/4-duty, OR previous day not a rest day.

        file-phpstat = text-010.

 

 

      ENDIF. "main php logic

 

 

 

 

* ---Public Holiday Pay (end)---

 

 

 

 

* -------------------------Shift Allowances-Actual (begin)--------------

 

 

 

 

*     shift type : 0-Not relevant, 1-Day to Day, 2-Day to Night,

*                  3-Night to Day, 4-Night to Night

*      IF file-acdhr > 0 AND file-acdhr <= 8.

*     In future may need to change to 8. (Teoh)

      IF file-acdhr > 0 AND file-acdhr <= 19.

        IF file-persk IN r_emasgss OR file-persk IN r_emasexs.

*         file-acact = '4' (Duty)

          IF ( file-acact = '4' OR file-acact = '3' ) AND

             ( NOT file-sdbtmindi IS INITIAL OR

               NOT file-sdetmindi IS INITIAL ).

**********************************************************************

            IF     file-sdbtmindi = 'Day' AND

                   file-sdetmindi = 'Day'.

              file-adswtype = 6013. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Day' AND

                   file-sdetmindi = 'Night'.

              file-adswtype = 6014. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Night' AND

                   file-sdetmindi = 'Day'.

              file-adswtype = 6015. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Night' AND

                   file-sdetmindi = 'Night'.

              file-adswtype = 6015. file-adsstat = '-'.

            ENDIF.

*         combination for sdbtm and sdetm indicators not found

          ELSE. "acact NE 4 or invalid sdbtm or invalid sdetm

* text-016:

* Error 16 : Actual shift activity not equals 'Duty (4)' OR

*            Scheduled duty begin/end time is empty (EMAS gs/exec).

            CONCATENATE file-adsstat

                        text-016

                   INTO file-adsstat.

          ENDIF. "actual duty shift allowance (EMAS gs/exec)

 

 

*       persk = erlgss OR erlexs

        ELSEIF file-persk IN r_erlgss OR file-persk IN r_erlexs.

*         file-acact = '4' (Duty)

          IF     ( file-acact = '4' OR file-acact = '3' ).

*            file-adswtype = 6014. file-adsstat = '-'.

*   file-adswtype = 6012. file-adsstat = '-'. "remarks by KAF 22/4/2004

*Add by KAF on 22/4/2004

            IF     file-sdbtmindi = 'Day' AND

                   file-sdetmindi = 'Day'.

              file-adswtype = 6013. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Day' AND

                   file-sdetmindi = 'Night'.

              file-adswtype = 6014. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Night' AND

                   file-sdetmindi = 'Day'.

              file-adswtype = 6012. file-adsstat = '-'.

            ELSEIF file-sdbtmindi = 'Night' AND

                   file-sdetmindi = 'Night'.

              file-adswtype = 6012. file-adsstat = '-'.

            ENDIF.

*            KAF end

          ELSE.

*****************************************************koonhon********

* text-017:

* Error 17 : Actual shift activity not equals 'Duty (4)'. (ERL gs/exec).

            CONCATENATE file-adsstat

                        text-017

                   INTO file-adsstat.

          ENDIF. "actual duty shift allowance (ERL gs/exec)

 

 

*       Not in file-persk range erl/emas gs/exec

        ELSE.

* text-018:

* Error 18 : Not in 'ERL/EMAS gs/exec' range for Actual Shift allowance.

          CONCATENATE file-adsstat

                      text-018

                 INTO file-adsstat.

        ENDIF. "file-persk

      ELSE. "acdhr >0 & <8

* text-019:

* Error 19 : Invalid actual shift hours (<= 0 OR > 8).

        CONCATENATE file-adsstat

                    text-019

               INTO file-adsstat.

      ENDIF. "adstype and acdhr

 

 

 

 

 

 

* ---Shift Allowances-Actual (end)---

 

 

    ELSE. "file-stat not equals '3'

* text-020: Error 20 : Status of employee 'INACTIVE' OR not in

*                     'Permanent' Employee Group.

      file-status  = text-020.

      file-phpstat = text-020.

      file-adsstat = text-020.

    ENDIF. "file-stat2 = '3'

 

 

*   Update record

    MODIFY file.

    CLEAR file.

 

 

  ENDLOOP. "file

 

 

ENDFORM. "add_additional_data

 

 

************************************************************************

*Fill in required values for upload

*batch_upload

*Includes:

*1) batch_upload - main function to map upload data & performing upload.

*2) fill_bdc - calls 3 functions (A,B,C) to update infotype

 

 

*A) bdc_dynpro

*B) bdc_field

*C) bdc_transaction

***********************************************************************

FORM batch_upload.

******************

* text-303 : Perform batch upload.

  WRITE: / text-303.

  logtab-log = text-303. APPEND logtab. CLEAR logtab.

 

 

 

 

  CONCATENATE 'pdate'

              'emp. no'

              'otdate'

              'Day Type'

              'Schd Actv'

              'Actual Actv'

              'Actual W Hrs'

              'OT hrs'

              'schd st time'

              'schd end time'

              'actual st time'

              'actual end time'

              'company'

              'prev ot dat'

              'prev ac act'

              'next ot dat'

              'next ac act'

              'wage type'

              'ot unit'

              'ot amt'

              'status'

              'php wtype'

              'php unit'

              'php stat'

              'sdbtmindi'

              'sdetmindi'

              'adswtype'

              'shiftunit'

              'shiftamt'

              'adsstat'

*add-on NOV new fields {start}

              'reason'

              'cbotwagetype'

*add-on NOV new fields {end}

*              'otswtype'

*              'otsstat'

         INTO logtab-log

  SEPARATED BY v_separator.

  APPEND logtab. CLEAR logtab.

 

 

* Maps required data to bdc

  LOOP AT file.

 

 

* Add to total record read counter.

    ADD 1 TO recread_tot.

 

 

 

 

 

 

*   ---For normal OT (start)---

*   Do not move to upload data if there are exceptions (for OT)

    IF file-status = '-' AND NOT file-wtype IS INITIAL.

 

 

*     Indicate action for OT

      acindi = 'ot'.

 

 

      CLEAR: record_2010.

*     Move required data essential for data upload.

      MOVE: file-pernr TO record_2010-pernr_001,

            file-otdat TO record_2010-begda_003,

            file-otdat TO record_2010-endda_004,

            file-otdat TO record_2010-begda_006,

            file-wtype TO record_2010-lgart_007.

 

 

*     Move other required data (unit)

      IF file-wtype = '6001' OR

         file-wtype = '6002'. "OR

        file-otunit = 1.

        MOVE: file-otunit TO record_2010-anzhl_009.

*     Move other required data (amount)

      ELSEIF file-wtype = '6016'.

        file-otamt = '15'.

        MOVE: file-otamt TO record_2010-betrg_010.

      ELSEIF file-wtype = '6017' OR

             file-wtype = '6018'.

        file-otamt = '45'.

        MOVE: file-otamt TO record_2010-betrg_010.

 

 

************************************************************************

      ELSEIF file-wtype = '6002' AND file-wtype2 ='6003'.

        record_2010-stdaz_012 = file-othrs - 8.

        record_2010-stdaz_008 = file-othrs.

 

 

*     ELSEIF file-wtype = '6004' AND file-wtype2 ='6005'.  rem by Teoh

      ELSEIF file-wtype2 ='6005'.

        record_2010-stdaz_012 = file-othrs - 8.

        record_2010-stdaz_008 = file-othrs.

************************************************koonhon02052002*********

*NO#001 {start}

      ELSEIF file-wtype = '6005'.

        record_2010-stdaz_012 = file-othrs - 8.

        record_2010-stdaz_008 = file-othrs.

*NO#001 {end}

      ELSE.

 

 

*     Move other required data (hours)

        MOVE: file-othrs TO record_2010-stdaz_008.

      ENDIF.

 

 

      APPEND record_2010.

 

 

 

 

*   Fills batch data and uploads data

      REFRESH bdc_tab.

      PERFORM fill_bdc_2010.

 

 

*   Clears the record_2010 table header.

      CLEAR record_2010.

 

 

    ELSE. "file-status NE '-' -> error for normal OT processing

*     Add count to rejected record (for status field not '-' only)

*     NOTE: 1st level of adding to recrej.

      ADD 1 TO recnup_ot.

 

 

*text-021: Error 21 : Wage type not detected.

      IF file-wtype IS INITIAL AND file-status IS INITIAL.

        file-status = text-021.

        MODIFY file.

      ENDIF.

 

 

    ENDIF. "file-status = '-'

*   ---For normal OT (end)---

 

 

**************  ADD_ON NOV '6003' {start}

    IF file-status2 = '-' AND NOT file-wtype2 IS INITIAL.

*       IF NOT file-wtype2 IS INITIAL.

      acindi = 'cb'.

 

 

      CLEAR: record_2010.

 

 

      MOVE: file-pernr TO record_2010-pernr_001,

            file-otdat TO record_2010-begda_003,

            file-otdat TO record_2010-endda_004,

            file-otdat TO record_2010-begda_006,

            file-wtype2 TO record_2010-lgart_007.

 

 

      IF file-wtype2 = '6003'.

        file-cback = file-acdhr - 8.

 

 

        MOVE: file-cback TO record_2010-stdaz_008.

      ENDIF.

 

 

      APPEND record_2010.

 

 

      REFRESH bdc_tab.

 

 

      PERFORM fill_bdc_2010.

 

 

      CLEAR record_2010.

 

 

    ELSE.

 

 

      IF file-wtype2 IS INITIAL AND file-status2 IS INITIAL.

        file-status2 = text-021.

        MODIFY file.

      ENDIF.

    ENDIF.

 

 

************* ADD_ON NOV '6003' {end}

 

 

 

 

 

 

*   ---For public holiday pay (start)---

*   Do not move to upload data if there are exceptions (for PHP)

    IF file-phpstat = '-' AND NOT file-phpwtype IS INITIAL.

 

 

*     Indicate action for OT

      acindi = 'php'.

 

 

      CLEAR: record_2010.

*     Move required data essential for data upload.

      MOVE: file-pernr TO record_2010-pernr_001,

            file-otdat TO record_2010-begda_003,

            file-otdat TO record_2010-endda_004,

            file-otdat TO record_2010-begda_006,

            file-phpwtype TO record_2010-lgart_007.

 

 

*     Move other required data (unit)

      IF file-phpwtype = '6004' OR file-phpwtype = '6006'.

        file-phpunit = 1.

        MOVE: file-phpunit TO record_2010-anzhl_009.

*     Move other required data (hours)

      ELSE.

        MOVE: file-acdhr TO record_2010-stdaz_008.

      ENDIF.

 

 

      APPEND record_2010.

 

 

*   Fills batch data and uploads data

      REFRESH bdc_tab.

      PERFORM fill_bdc_2010.

 

 

*   Clears the record_2010 table header.

      CLEAR record_2010.

 

 

    ELSE. "file-status NE '-' -> error for normal OT processing

*     Add count to rejected record (for status field not '-' only)

*     NOTE: 1st level of adding to recrej.

      ADD 1 TO recnup_php.

 

 

*text-021: Error 21 : Wage type not detected.

      IF file-phpwtype IS INITIAL AND file-phpstat IS INITIAL.

        file-phpstat = text-021.

        MODIFY file.

      ENDIF.

 

 

 

 

    ENDIF. "file-phpstat = '-'

*   ---For public holiday pay (end)---

 

 

 

 

*   ---For actual duty shift allowance (start)---

*   Do not move to upload data if there are exceptions (for OT)

    IF file-adsstat = '-' AND NOT file-adswtype IS INITIAL.

 

 

*     Indicate action for Actual Duty Shift allowance

      acindi = 'ads'.

 

 

      CLEAR: record_2010.

*     Move required data essential for data upload.

      MOVE: file-pernr TO record_2010-pernr_001,

            file-otdat TO record_2010-begda_003,

            file-otdat TO record_2010-endda_004,

            file-otdat TO record_2010-begda_006,

            file-adswtype TO record_2010-lgart_007.

 

 

 

 

*     Move other required data (in unit)

      IF file-adswtype = '6012' OR

         file-adswtype = '6013' OR

         file-adswtype = '6014' OR

         file-adswtype = '6015'.

*        file-shiftunit = file-acdhr.

*        DIVIDE file-shiftunit BY 8.

        IF file-acdhr GT 4.

          file-shiftunit = 1.

        ELSEIF ( file-acdhr GT 0 ) AND ( file-acdhr LT 5 ).

          file-shiftunit = ( 1 / 2 ).

        ENDIF.

        MOVE: file-shiftunit TO record_2010-anzhl_009.

*     Move other required data (hours)

      ELSE.

        MOVE: file-acdhr TO record_2010-stdaz_008.

      ENDIF.

 

 

      APPEND record_2010.

 

 

*   Fills batch data and uploads data

      REFRESH bdc_tab.

      PERFORM fill_bdc_2010.

 

 

*   Clears the record_2010 table header.

      CLEAR record_2010.

 

 

    ELSE. "file-status NE '-' -> error for normal OT processing

*     Add count to rejected record (for status field not '-' only)

*     NOTE: 1st level of adding to recrej.

      ADD 1 TO recnup_ads.

 

 

*text-021: Error 21 : Wage type not detected.

      IF file-adswtype IS INITIAL AND file-adsstat IS INITIAL.

        file-adsstat = text-021.

        MODIFY file.

      ENDIF.

 

 

    ENDIF. "file-adsstat = '-'

*   ---actual duty shift allowance (end)---

 

 

 

 

*   Combines contents of successful records.

    WRITE file-othrs TO othrschar.

    WRITE file-salary TO salarychar.

    WRITE file-acdhr TO acdhrchar.

    WRITE file-otunit TO otunitchar.

    WRITE file-otamt TO otamtchar.

    WRITE file-shiftunit TO shiftunitchar.

    WRITE file-shiftamt TO shiftamtchar.

    WRITE file-phpunit TO phpunitchar.

 

 

    CONCATENATE file-pdate

                file-pernr+2(6)

                file-otdat

                file-mbwtype

                file-scact

                file-acact

                acdhrchar

                othrschar

                file-sdbtm

                file-sdetm

                file-adbtm

                file-adetm

                file-werks

                file-prevotdat

                file-prevacact

                file-nextotdat

                file-nextacact

                file-wtype

                otunitchar

                otamtchar

                file-status

                file-phpwtype

                phpunitchar

                file-phpstat

                file-sdbtmindi

                file-sdetmindi

                file-adswtype

                shiftunitchar

                shiftamtchar

                file-adsstat

                file-extra3

                file-wtype2

           INTO logtab-log

    SEPARATED BY v_separator.     .

    APPEND logtab. CLEAR logtab.

 

 

 

 

    CLEAR file.

 

 

  ENDLOOP. "file

 

 

 

 

ENDFORM. "batch_upload

 

 

 

 

**********************************************************************

FORM create_session.

********************

  CALL FUNCTION 'BDC_OPEN_GROUP'

       EXPORTING

            client = sy-mandt

            group  = c_session

            keep   = 'X'

            user   = sy-uname.

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

 

 

* text-304 : Session created :

  WRITE: / text-304, sy-uname.

  CONCATENATE text-304 sy-uname ' .' INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

ENDFORM. "create_session

 

 

 

 

***********************************************************************

FORM fill_bdc_2010.

*******************

  PERFORM bdc_dynpro      USING 'SAPMP50A' '1000'.

  PERFORM bdc_field       USING 'BDC_OKCODE'

                                '=INS'.

  PERFORM bdc_field       USING 'RP50G-PERNR'

                                record_2010-pernr_001.

  PERFORM bdc_field       USING 'RP50G-TIMR6'

*                                record_2010-TIMR6_002.

                                'X'.

  PERFORM bdc_field       USING 'RP50G-BEGDA'

                                record_2010-begda_003.

  PERFORM bdc_field       USING 'RP50G-ENDDA'

                                record_2010-endda_004.

  PERFORM bdc_field       USING 'BDC_CURSOR'

                                'RP50G-CHOIC'.

  PERFORM bdc_field       USING 'RP50G-CHOIC'

*                                record_2010-CHOIC_005.

                                '2010'.

  PERFORM bdc_dynpro      USING 'MP200000' '2450'.

  PERFORM bdc_field       USING 'BDC_CURSOR'

                                'P2010-STDAZ'.

  PERFORM bdc_field       USING 'BDC_OKCODE'

                                '=UPD'.

  PERFORM bdc_field       USING 'P2010-BEGDA'

                                record_2010-begda_006.

  PERFORM bdc_field       USING 'P2010-LGART'

                                record_2010-lgart_007.

  PERFORM bdc_field       USING 'P2010-STDAZ'

                                record_2010-stdaz_008.

  PERFORM bdc_field       USING 'P2010-ANZHL'

                                record_2010-anzhl_009.

  PERFORM bdc_field       USING 'P2010-BETRG'

                                record_2010-betrg_010.

  PERFORM bdc_field       USING 'P2010-WAERS'

*                                record_2010-WAERS_009.

*                                'MYR'.

                                'RM'.

************************************************************************

  IF NOT record_2010-stdaz_012 IS INITIAL.

 

 

    PERFORM bdc_dynpro      USING 'SAPMP50A' '1000'.

    PERFORM bdc_field       USING 'BDC_OKCODE'

                                  '=INS'.

    PERFORM bdc_field       USING 'RP50G-PERNR'

                                  record_2010-pernr_001.

    PERFORM bdc_field       USING 'RP50G-TIMR6'

*                                record_2010-TIMR6_002.

                                  'X'.

    PERFORM bdc_field       USING 'RP50G-BEGDA'

                                  record_2010-begda_003.

    PERFORM bdc_field       USING 'RP50G-ENDDA'

                                  record_2010-endda_004.

    PERFORM bdc_field       USING 'BDC_CURSOR'

                                  'RP50G-CHOIC'.

    PERFORM bdc_field       USING 'RP50G-CHOIC'

*                                record_2010-CHOIC_005.

                                  '2010'.

    PERFORM bdc_dynpro      USING 'MP200000' '2450'.

    PERFORM bdc_field       USING 'BDC_CURSOR'

                                  'P2010-STDAZ'.

    PERFORM bdc_field       USING 'BDC_OKCODE'

                                  '=UPD'.

    PERFORM bdc_field       USING 'P2010-BEGDA'

                                  record_2010-begda_006.

    PERFORM bdc_field       USING 'P2010-LGART'

*                                record_2010-lgart_007.

                                  '6000'.

    PERFORM bdc_field       USING 'P2010-STDAZ'

                                  record_2010-stdaz_012.

    PERFORM bdc_field       USING 'P2010-ANZHL'

                                  record_2010-anzhl_009.

    PERFORM bdc_field       USING 'P2010-BETRG'

                                  record_2010-betrg_010.

    PERFORM bdc_field       USING 'P2010-WAERS'

*                                record_2010-WAERS_009.

*                                'MYR'.

                                  'RM'.

  ELSE.

  ENDIF.

 

 

**********************************************koonhon02052002***********

 

 

  PERFORM bdc_transaction USING 'PA30'.

 

 

 

 

ENDFORM. "fill_bdc_2010

 

 

 

 

************************************************************************

FORM bdc_dynpro USING program dynpro.

*************************************

  CLEAR bdc_tab.

  bdc_tab-program  = program.

  bdc_tab-dynpro   = dynpro.

  bdc_tab-dynbegin = 'X'.

  APPEND bdc_tab.

ENDFORM. "bdc_dynpro

 

 

 

 

***********************************************************************

FORM bdc_field USING fnam fval.

*******************************

  IF fval <> '/'. "NODATA.

    CLEAR bdc_tab.

    bdc_tab-fnam = fnam.

    bdc_tab-fval = fval.

    APPEND bdc_tab.

  ENDIF.

 

 

ENDFORM. "bdc_field

 

 

 

 

***********************************************************************

FORM bdc_transaction USING tcode.

*********************************

  DATA: l_mstring(480).

  DATA: l_subrc LIKE sy-subrc.

* batch input session

  IF NOT c_session IS INITIAL.

    CALL FUNCTION 'BDC_INSERT'

         EXPORTING

              tcode     = tcode

         TABLES

              dynprotab = bdc_tab.

*    IF SMALLLOG <> 'X'.

**************************************

*    WRITE: / 'BDC_INSERT'(i03),

*             tcode,

*             'returncode:'(i05),

*             sy-subrc,

*             'RECORD:',

*             sy-index.

 

 

*  WRITE tcode TO char1.

*  WRITE sy-subrc TO char2.

*  WRITE sy-index TO char3.

 

 

*  CONCATENATE 'BDC_INSERT : ' char1 '.' ' returncode : ' char2 '. '

*  'RECORD : ' char3 ' | ' INTO excepmsg1.

 

 

***************************************

 

 

*    ENDIF.

* call transaction using

  ELSE.

*    REFRESH messtab.

*    CALL TRANSACTION tcode USING bdc_tab

*                     MODE cdismode

*                     UPDATE cupdmode

*                     MESSAGES INTO messtab.

    l_subrc = sy-subrc.

*    IF SMALLLOG <> 'X'.

 

 

**************************************

*    WRITE: / 'CALL_TRANSACTION',

*             tcode,

*             'returncode:'(i05),

*             l_subrc,

*             'RECORD:',

*             sy-index.

 

 

*    WRITE tcode TO char1.

*    WRITE l_subrc TO char2.

*    WRITE sy-index TO char3.

*

*    CONCATENATE 'CALL_TRANSACTION : ' char1 '.' ' returncode : ' char2

*    '.' ' RECORD : ' char3 ' | ' INTO excepmsg2.

 

 

*  Logic added to account for records with wagetype but rejected due to

*     other reasons. NOTE: 2nd level of adding to recrej.

*    IF l_subrc <> 0.

*      IF     acindi = 'ot'.

*        ADD 1 TO recrej_ot.

*      ELSEIF acindi = 'php'.

*        ADD 1 TO recrej_php.

*      ELSEIF acindi = 'ads'.

*        ADD 1 TO recrej_ads.

**      ELSEIF acindi = 'ots'.

**        ADD 1 TO recrej_ots.

*      ENDIF. "acindi

*    ENDIF. "l_subrc <> 0

***************************************

 

 

*    LOOP AT messtab.

*      SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra

*                                AND   arbgb = messtab-msgid

*                                AND   msgnr = messtab-msgnr.

*      IF sy-subrc = 0.

*        l_mstring = t100-text.

*        IF l_mstring CS '&1'.

*          REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.

*          REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.

*          REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.

*          REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.

*        ELSE.

*          REPLACE '&' WITH messtab-msgv1 INTO l_mstring.

*          REPLACE '&' WITH messtab-msgv2 INTO l_mstring.

*          REPLACE '&' WITH messtab-msgv3 INTO l_mstring.

*          REPLACE '&' WITH messtab-msgv4 INTO l_mstring.

*        ENDIF. "l_mstring CS '&1'

***************************************

*       WRITE: / messtab-msgtyp, l_mstring(250).

*        IF excepmsg3 IS INITIAL.

*          CONCATENATE messtab-msgtyp ' - ' l_mstring ' | '

*          INTO excepmsg3.

*        ELSE.

*          CONCATENATE excepmsg3 messtab-msgtyp ' - ' l_mstring

*          ' | ' INTO excepmsg3.

*        ENDIF. "excepmsg3 IS INITIAL

*

***************************************

*      ELSE.

***************************************

*       WRITE: / messtab.

 

 

*        IF excepmsg3 IS INITIAL.

*          CONCATENATE messtab ' | ' INTO excepmsg3.

*        ELSE.

*          CONCATENATE excepmsg3 messtab ' | ' INTO excepmsg3.

*        ENDIF. "excepmsg3 IS INITIAL

 

 

***************************************

*      ENDIF. "sy-subrc = 0

 

 

*    ENDLOOP. " at messtab

 

 

*    ENDIF.

* Erzeugen fehlermappe ************************************************

*    IF L_SUBRC <> 0 AND E_GROUP <> SPACE.

*      IF E_GROUP_OPENED = ' '.

*        CALL FUNCTION 'BDC_OPEN_GROUP'

*             EXPORTING  CLIENT   = SY-MANDT

*                        GROUP    = E_GROUP

*                        USER     = E_USER

*                        KEEP     = E_KEEP

*                        HOLDDATE = E_HDATE.

*         E_GROUP_OPENED = 'X'.

*      ENDIF.

*      CALL FUNCTION 'BDC_INSERT'

*           EXPORTING TCODE     = TCODE

*           TABLES    DYNPROTAB = BDC_tab.

*    ENDIF.

  ENDIF. "sy-subrc <>0

  REFRESH bdc_tab.

 

 

** Combines 3 transaction status messages into the exception field

*  CONCATENATE excepmsg1 excepmsg2 excepmsg3 INTO excepmsg_com.

*

** Provide feedback on successful records OR

** successfull overwritten records

** Includes : 2nd level checking for record rejection

*  SEARCH excepmsg_com FOR 'Record created'.

*  searchres1 = sy-subrc.

*  SEARCH excepmsg_com FOR 'This entry deletes a record'.

*  searchres2 = sy-subrc.

 

 

  IF     acindi = 'ot'.

*    file-status = excepmsg_com.

    file-status = text-800.

    MODIFY file.

    ADD 1 to ot_records.

*    IF     searchres1 = 0 AND searchres2 = 0.

*      ADD 1 to recdel_ot.

*    ELSEIF searchres1 = 0 AND searchres2 = 4.

*      ADD 1 to recnew_ot.

*    ENDIF. "searchres

 

 

  ELSEIF acindi = 'php'.

*    file-phpstat = excepmsg_com.

    file-phpstat = text-800.

    MODIFY file.

    ADD 1 to php_records.

*    IF     searchres1 = 0 AND searchres2 = 0.

*      ADD 1 to recdel_php.

*    ELSEIF searchres1 = 0 AND searchres2 = 4.

*      ADD 1 to recnew_php.

*    ENDIF. "searchres

 

 

  ELSEIF acindi = 'ads'.

*    file-adsstat = excepmsg_com.

    file-adsstat = text-800.

    MODIFY file.

    ADD 1 to sa_records.

*    IF     searchres1 = 0 AND searchres2 = 0.

*      ADD 1 to recdel_ads.

*    ELSEIF searchres1 = 0 AND searchres2 = 4.

*      ADD 1 to recnew_ads.

*    ENDIF. "searchres

 

 

*  ELSEIF acindi = 'ots'.

*    file-otsstat = excepmsg_com.

*    MODIFY file.

*    IF     searchres1 = 0 AND searchres2 = 0.

*      ADD 1 to recdel_ots.

*    ELSEIF searchres1 = 0 AND searchres2 = 4.

*      ADD 1 to recnew_ots.

*    ENDIF. "searchres

*

 

 

  ENDIF. "acindi

 

 

** Clear excepmsg1,2,3, messtab for next loop.

*  CLEAR: excepmsg1, excepmsg2, excepmsg3, messtab.

 

 

ENDFORM. "bdc_transaction

 

 

************************************************************************

FORM close_session.

*******************

  CALL FUNCTION 'BDC_CLOSE_GROUP'

*   EXCEPTIONS

*     NOT_OPEN          = 1

*     QUEUE_ERROR       = 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.

 

 

* text-306 : Session closed :

  WRITE: / text-306, sy-uname.

  CONCATENATE text-306 sy-uname INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

ENDFORM. "close_session

 

 

************************************************************************

* Autosubmit_BDC

************************************************************************

FORM AUTOSUBMIT_BDC USING V_SESS.

  SUBMIT RSBDCSUB WITH MAPPE EQ V_SESS

                  WITH VON EQ SY-DATUM

                  WITH BIS EQ SY-DATUM

                  WITH Z_VERARB EQ 'X'

                  WITH FEHLER EQ ''

                  WITH LOGALL EQ 'X'

                  TO SAP-SPOOL DESTINATION ''

                               IMMEDIATELY ''

                               KEEP IN SPOOL 'X'

                               WITHOUT SPOOL DYNPRO

                  AND RETURN.

*  IF SY-SUBRC NE 0.

*    PERFORM INSERT_ERROR USING

*    'GENERAL' 'Claims batch submission error'.

*  ELSE.

**    V_OKAY = 'X'.

*  ENDIF.

ENDFORM.

 

 

************************************************************************

FORM write_file.

****************

* text-101 : Total lines read :

  WRITE: / text-101, recread_tot LEFT-JUSTIFIED.

  CONCATENATE text-101 recread_tot INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

* text-801 : Total OT transactions created :

  WRITE: / text-801, ot_records LEFT-JUSTIFIED.

  CONCATENATE text-801 ot_records INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

* text-802 : Total Public Holiday Pay transactions created :

  WRITE: / text-802, php_records LEFT-JUSTIFIED.

  CONCATENATE text-802 php_records INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

* text-803 : Total Shift Allowances transactions created :

  WRITE: / text-803, sa_records LEFT-JUSTIFIED.

  CONCATENATE text-803 sa_records INTO logtab-log.

  APPEND logtab. CLEAR logtab.

 

 

** ---Normal OT (start)---

** text-103 : Total normal OT lines succeeded :

** text-105 : Overwritten :

** text-106 : New :

*  ADD recnew_ot TO recsucc_ot.

*  ADD recdel_ot TO recsucc_ot.

*

*  WRITE: / text-103, recsucc_ot, ' ( ', text-106, recnew_ot, ' , ',

*           text-105, recdel_ot, ' )'.

*

*  CONCATENATE text-103 recsucc_ot ' ( '

*              text-106 recnew_ot ' , '

*              text-105 recdel_ot ' )'

*              INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** text-116 : Total normal OT lines not uploaded :

*  WRITE: / text-116, recnup_ot.

*  CONCATENATE text-116 recnup_ot ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-102 : Total normal OT lines rejected :

*  WRITE: / text-102, recrej_ot.

*  CONCATENATE text-102 recrej_ot ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-104 : Total normal OT lines with partial success/reject :

*  recpart_ot = recread_tot.

*  SUBTRACT recsucc_ot FROM recpart_ot.

*  SUBTRACT recrej_ot  FROM recpart_ot.

*  SUBTRACT recnup_ot  FROM recpart_ot.

*  WRITE: / text-104, recpart_ot LEFT-JUSTIFIED.

*  CONCATENATE text-104 recpart_ot INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** ---Normal OT (end)---

*

** ---Public Holiday Pay (start)---

** text-107 : Total Public Holiday Pay items succeeded :

** text-105 : Overwritten :

** text-106 : New :

*  ADD recnew_php TO recsucc_php.

*  ADD recdel_php TO recsucc_php.

*

*  WRITE: / text-107, recsucc_php, ' ( ',

*           text-106, recnew_php, ' , ',

*           text-105, recdel_php, ' )'.

*

*  CONCATENATE text-107 recsucc_php ' ( '

*              text-106 recnew_php ' , '

*              text-105 recdel_php ' )'

*              INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** text-117 : Total Public Holiday Pay items not uploaded :

*  WRITE: / text-117, recnup_php.

*  CONCATENATE text-117 recnup_php ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-108 : Total Public Holiday Pay items rejected :

*  WRITE: / text-108, recrej_php.

*  CONCATENATE text-108 recrej_php ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-109 :

** Total Public Holiday Pay items with partial success/reject :

*  recpart_php = recread_tot.

*  SUBTRACT recsucc_php FROM recpart_php.

*  SUBTRACT recrej_php  FROM recpart_php.

*  SUBTRACT recnup_php  FROM recpart_php.

*  WRITE: / text-109, recpart_php LEFT-JUSTIFIED.

*  CONCATENATE text-109 recpart_php INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** ---Public Holiday Pay (end)---

*

** ---Actual Shift Duty (start)---

** text-110 : Total Actual Shift Duty items succeeded :

** text-105 : Overwritten :

** text-106 : New :

*  ADD recnew_ads TO recsucc_ads.

*  ADD recdel_ads TO recsucc_ads.

*

*  WRITE: / text-110, recsucc_ads, ' ( ',

*           text-106, recnew_ads, ' , ',

*           text-105, recdel_ads, ' )'.

*

*  CONCATENATE text-110 recsucc_ads ' ( '

*              text-106 recnew_ads ' , '

*              text-105 recdel_ads ' )'

*              INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** text-118 : Total Actual Shift Duty items not uploaded :

*  WRITE: / text-118, recnup_ads.

*  CONCATENATE text-118 recnup_ads ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-111 : Total Actual Shift Duty items rejected :

*  WRITE: / text-111, recrej_ads.

*  CONCATENATE text-111 recrej_ads ' .' INTO logtab-log. APPEND logtab.

*  CLEAR logtab.

*

** text-112 : Total Actual Duty Shift items with partial

**            success/reject :

*  recpart_ads = recread_tot.

*  SUBTRACT recsucc_ads FROM recpart_ads.

*  SUBTRACT recrej_ads  FROM recpart_ads.

*  SUBTRACT recnup_ads  FROM recpart_ads.

*  WRITE: / text-112, recpart_ads LEFT-JUSTIFIED.

*  CONCATENATE text-112 recpart_ads INTO logtab-log.

*  APPEND logtab. CLEAR logtab.

*

** ---Actual Shift Duty (end)---

*

*** ---OT Shift (start)---

*** text-113 : Total OT Shift items succeeded :

*** text-105 : Overwritten :

*** text-106 : New :

**  ADD recnew_ots TO recsucc_ots.

**  ADD recdel_ots TO recsucc_ots.

**

**  WRITE: / text-113, recsucc_ots, ' ( ',

**           text-106, recnew_ots, ' , ',

**           text-105, recdel_ots, ' )'.

**

**  CONCATENATE text-113 recsucc_ots ' ( '

**              text-106 recnew_ots ' , '

**              text-105 recdel_ots ' )'

**              INTO logtab-log.

**  APPEND logtab. CLEAR logtab.

**

*** text-119 : Total OT Shift items not uploaded :

**  WRITE: / text-119, recnup_ots.

**  CONCATENATE text-119 recnup_ots ' .' INTO logtab-log. APPEND logtab.

**  CLEAR logtab.

**

*** text-114 : Total OT Shift items rejected :

**  WRITE: / text-114, recrej_ots.

**  CONCATENATE text-114 recrej_ots ' .' INTO logtab-log. APPEND logtab.

**  CLEAR logtab.

**

*** text-115 : Total OT Shift items with partial

***            success/reject :

**  recpart_ots = recread_tot.

**  SUBTRACT recsucc_ots FROM recpart_ots.

**  SUBTRACT recrej_ots  FROM recpart_ots.

**  SUBTRACT recnup_ots  FROM recpart_ots.

**  WRITE: / text-115, recpart_ots LEFT-JUSTIFIED.

**  CONCATENATE text-115 recpart_ots INTO logtab-log.

**  APPEND logtab. CLEAR logtab.

**

*** ---OT Shift (end)---

*

 

 

  SKIP.

  WRITE:

    /0  'pdate',

    10  'pernr',                                            "8  char

    20  'otdate',                                           "8  char

*    10  'start_tm',

*    20  'end_tm',

    30  'mbwtype',                                          "3  char

    40  'scact',                                            "25 char

    50  'acact',

    60  'acdhr',

    70  'othrs',

    80  'persg',

    90  'persk',

    100  'sdbtm',

    110 'sdetm',

    120 'adbtm',

    130 'adetm',

*    140 'salary',

    150 'werks',

*    160 'persk',

    170 'stat2',

    180 'prevotdat',

    190 'prevacact',

    200 'nextotdat',

    210 'nextacact',

    220 'wtype',

    230 'otunit',

    240 'otamt',

    260 'status',

    310 'phpwtype',

    320 'phpunit',

    330 'phpstat',

    380 'sdbtmindi',

    390 'sdetmindi',

    400 'adswtype',

    410 'shiftunit',

    420 'shiftamt',

*    440 'adsstat'.  " yap

    440 'adsstat',   " yap

*    450 'start_tm',    " yap

*    460 'end_tm'.      " yap

     450 'reason',      " yap

     460 'cbotwagetype'. " yap

 

 

*    350 'otswtype',

*    360 'otsstat.

 

 

 

 

  ULINE.

 

 

  LOOP AT file.

    WRITE:

    /0  file-pdate,

    10  file-pernr+2(6),                                    "8  char

    20  file-otdat,                                         "8  char

    30  file-mbwtype,                                       "3  char

    30  end_tm,

    40  file-scact,                                         "25 char

    50  file-acact,

    60  file-acdhr,

    70  file-othrs,

*    70  start_tm,    " yap

    80  file-persg,

*    80  end_tm,      " yap

    90  file-persk,

    100 file-sdbtm,

    110 file-sdetm,

    120 file-adbtm,

    130 file-adetm,

*    140 file-salary,

    150 file-werks,

*    160 file-persk,

    170 file-stat2,

    180 file-prevotdat,

    190 file-prevacact,

    200 file-nextotdat,

    210 file-nextacact,

    220 file-wtype,

    230 file-otunit,

    240 file-otamt,

    260 file-status,

    310 file-phpwtype,

    320 file-phpunit,

    330 file-phpstat,

    380 file-sdbtmindi,

    390 file-sdetmindi,

    400 file-adswtype,

    410 file-shiftunit,

    420 file-shiftamt,

*    440 file-adsstat.  " yap

    440 file-adsstat,

*    450  start_tm,    " yap

*    460  end_tm,      " yap

*    480  tot,

*    500  file-finalstart, " yap

*    520  file-finalend,

*    530  file-otleaveindi, " yap

*    540  file-extra1,

*    550  file-extra2,

    460  file-extra3,

    470  file-wtype2.

*    350 file-otswtype,

*    360 file-otsstat.

 

 

  ENDLOOP.

 

 

*SKIP. SKIP.

*  LOOP AT logtab.

*    WRITE: /0 logtab-log.

*  ENDLOOP. "logtab

 

 

ENDFORM. "write_file

 

 

************************************************************************

FORM output_log.

****************

*ADD recrej_ot  TO recrej_tot.

*ADD recnup_ot  TO recrej_tot.

*ADD recrej_php TO recrej_tot.

*ADD recnup_php  TO recrej_tot.

*ADD recrej_ads TO recrej_tot.

*ADD recrej_ots TO recrej_tot.

*DIVIDE recrej_tot BY 4.

 

 

** Append status to output log file

*  IF     recsucc_ot  = 0 AND

*         recsucc_php = 0 AND

*         recsucc_ads = 0.

**         recsucc_ots = 0.

*    uploadstat = 'failed'.

*  ELSE.

*    uploadstat = 'processed'.

*  ENDIF. "record read / rejected

 

 

 

 

* Name log file by concatenating original name OT_ddmmyyyy_nn with

* session name.

 

 

 

 

*  SEARCH p_file FOR '.OTMBUS_.'.

*  CONCATENATE '\\Express05\SAP-HR\80 - Working Directories\'

*              'Chin Kuan\processed\'

*              p_file+sy-fdpos(18) '_'

*              session '_'

*              sy-uzeit '_'

*              uploadstat '.txt'

*         INTO log_name.

 

 

  LOOP AT logtab.

    APPEND logtab-log TO outputtab.

  ENDLOOP. "logtab.

 

 

  log_name = p_log.

* log_name = 'C:\outputfile1.txt'.

  log_type = 'ASC'.

 

 

  CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

          filename = log_name

          filetype = log_type

 

 

    IMPORTING

          filelength = flenlog

 

 

*    IMPORTING

*       VALUE(BIN_FILESIZE) DEFAULT SPACE

*       VALUE(CODEPAGE) DEFAULT SPACE

*       VALUE(FILENAME) LIKE  RLGRAP-FILENAME DEFAULT SPACE

*       VALUE(FILETYPE) LIKE  RLGRAP-FILETYPE DEFAULT 'ASC'

*       VALUE(MODE) DEFAULT SPACE

*       VALUE(WK1_N_FORMAT) DEFAULT SPACE

*       VALUE(WK1_N_SIZE) DEFAULT SPACE

*       VALUE(WK1_T_FORMAT) DEFAULT SPACE

*       VALUE(WK1_T_SIZE) DEFAULT SPACE

*       VALUE(COL_SELECT) DEFAULT SPACE

*       VALUE(COL_SELECTMASK) DEFAULT SPACE

*       VALUE(NO_AUTH_CHECK) TYPE  C DEFAULT SPACE

 

 

    TABLES

        data_tab                   = outputtab

*        FIELDNAMES                 = log

*        FIELDNAMES OPTIONAL

    EXCEPTIONS

        file_open_error            = 1

        file_write_error           = 2

        invalid_filesize           = 3

        invalid_type               = 4

        no_batch                   = 5

        unknown_error              = 6

        invalid_table_width        = 7

        gui_refuse_filetransfer    = 8

        customer_error             = 9.

 

 

  IF sy-subrc <> 0.

*      Write to file flat file read error.

    CASE sy-subrc.

      WHEN 01.

        WRITE 'WS_DOWNLOAD error : file_open_error'.

      WHEN 02.

        WRITE 'WS_DOWNLOAD error : file_write_error'.

      WHEN 03.

        WRITE 'WS_DOWNLOAD error : invalid_filesize'.

      WHEN 04.

        WRITE 'WS_DOWNLOAD error : invalid_type'.

      WHEN 05.

        WRITE 'WS_DOWNLOAD error : no_batch'.

      WHEN 06.

        WRITE 'WS_DOWNLOAD error : unknown_error'.

      WHEN 07.

        WRITE 'WS_DOWNLOAD error : invalid_table_width'.

      WHEN 08.

        WRITE 'WS_DOWNLOAD error : gui_refuse_filetransfer'.

      WHEN 09.

        WRITE 'WS_DOWNLOAD error : customer_error'.

    ENDCASE.

  ENDIF. "sy_subrc.

 

 

  WRITE: / 'Log file saved : ', log_name.

  WRITE: / 'File length downloaded : ', flenlog.

 

 

 

 

ENDFORM. "output_log.

 

 

************************************************************************

FORM LogFile_DOWNLOAD TABLES   outputtab

                      USING    p_log log_type

                      CHANGING P_VALUE.

*                            P_MESSAGE.

 

 

  LOOP AT logtab.

    APPEND logtab-log TO outputtab.

  ENDLOOP. "logtab.

 

 

  log_type = 'ASC'.

 

 

*{   REPLACE        ECDK901215                                        1

*\* Download log file--------------------------------------------------*

*\  OPEN DATASET p_log FOR OUTPUT IN TEXT MODE.

*\

*\*    MOVE SY-SUBRC TO P_VALUE .

*\*    P_MESSAGE = L_MESSAGE.

*\

*\  IF SY-SUBRC EQ 0 .

*\    LOOP AT outputtab.

*\      TRANSFER outputtab TO p_log.

*\    ENDLOOP.

*\    CLOSE DATASET p_log.

*\  ENDIF.

*\

*\  WRITE: / 'Log file saved : ', p_log.

* Download log file--------------------------------------------------*

IF cb_manu EQ 'X' AND p_log2 NE intfpath2. "manual download to local desktop

  DATA: tmp_log TYPE string.

 

 

  tmp_log = p_log2.

 

 

  CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

      FILENAME                        = tmp_log

      FILETYPE                        = 'ASC'

      WRITE_FIELD_SEPARATOR           = 'X'

    TABLES

      DATA_TAB                        = outputtab

    EXCEPTIONS

      FILE_WRITE_ERROR                = 1

      NO_BATCH                        = 2

      GUI_REFUSE_FILETRANSFER         = 3

      INVALID_TYPE                    = 4

      NO_AUTHORITY                    = 5

      UNKNOWN_ERROR                   = 6

      HEADER_NOT_ALLOWED              = 7

      SEPARATOR_NOT_ALLOWED           = 8

      FILESIZE_NOT_ALLOWED            = 9

      HEADER_TOO_LONG                 = 10

      DP_ERROR_CREATE                 = 11

      DP_ERROR_SEND                   = 12

      DP_ERROR_WRITE                  = 13

      UNKNOWN_DP_ERROR                = 14

      ACCESS_DENIED                   = 15

      DP_OUT_OF_MEMORY                = 16

      DISK_FULL                       = 17

      DP_TIMEOUT                      = 18

      FILE_NOT_FOUND                  = 19

      DATAPROVIDER_EXCEPTION          = 20

      CONTROL_FLUSH_ERROR             = 21

      OTHERS                          = 22.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ELSE.

    WRITE: / 'Log file saved : ', p_log.

  ENDIF.

 

 

ELSE.

  IF SY-SUBRC EQ 0 .

    LOOP AT outputtab.

      TRANSFER outputtab TO p_log.

    ENDLOOP.

    CLOSE DATASET p_log.

    WRITE: / 'Log file saved : ', p_log.

  ENDIF.

ENDIF.

*}   REPLACE

 

 

ENDFORM.

************************************************************************

FORM pop_prev_n_next_acact USING curotdate LIKE file-otdat

                                 curpernr  LIKE file-pernr.

************************************************************

 

 

* NEXT DATE PROCESSING

* Obtain next date from the current OT date

  CLEAR: nextotdat_char.

* Convert ddmmyyyy to dd.mm.yyyy

  CONCATENATE curotdate(2) '.'

              curotdate+2(2) '.'

              curotdate+4(4)

         INTO nextotdat_char.

  CALL FUNCTION 'DATE_IN_FUTURE'

       EXPORTING

            ANZAHL_TAGE             = 1

            IMPORT_DATUM            = nextotdat_char

       IMPORTING

            EXPORT_DATUM_EXT_FORMAT = nextotdat_char.

*      EXPORT_DATUM_INT_FORMAT LIKE SY-DATUM

 

 

* Convert dd.mm.yyyy to ddmmyyyy

  CONCATENATE nextotdat_char(2)

              nextotdat_char+3(2)

              nextotdat_char+6(4)

         INTO nextotdat.

* Read internal table to find next actual activity

  CLEAR: wa_file.

  READ TABLE file

  WITH KEY   otdat = nextotdat

             pernr = curpernr

*  BINARY SEARCH

  INTO       wa_file.

 

 

* If next day record is found.

  IF sy-subrc = 0.

    MOVE: wa_file-otdat TO file-nextotdat.

    MOVE: wa_file-acact TO file-nextacact.

  ELSE. "no next day record found.

************************************************************************

    file-nextacact = '1'.

*************************************************koonhon****************

 

 

** Text-022 : Error 22 : Next day record not found.

*    CONCATENATE file-status  text-022 INTO file-status.

*    CONCATENATE file-phpstat text-022 INTO file-phpstat.

**    CONCATENATE file-otsstat text-022 INTO file-otsstat.

*    CONCATENATE file-adsstat text-022 INTO file-adsstat.

  ENDIF. "next day record

 

 

 

 

* PREVIOUS DATE PROCESSING

* Obtain previous date from the current OT date

*  CLEAR: prevotdat.

  CLEAR: prevotdat_char.

 

 

* Convert ddmmyyyy to dd.mm.yyyy

  CONCATENATE curotdate(2) '.'

              curotdate+2(2) '.'

              curotdate+4(4)

         INTO prevotdat_char.

 

 

  CALL FUNCTION 'DATE_IN_FUTURE'

       EXPORTING

            ANZAHL_TAGE             = -1

            IMPORT_DATUM            = prevotdat_char

       IMPORTING

            EXPORT_DATUM_EXT_FORMAT = prevotdat_char.

 

 

* Convert dd.mm.yyyy to ddmmyyyy

  CONCATENATE prevotdat_char(2)

              prevotdat_char+3(2)

              prevotdat_char+6(4)

         INTO prevotdat.

 

 

* Read internal table to find previous actual activity

  CLEAR: wa_file.

  READ TABLE file

  WITH KEY   otdat = prevotdat

             pernr = curpernr

*  BINARY SEARCH

  INTO       wa_file.

 

 

* If previous day record is found.

  IF sy-subrc = 0.

    MOVE: wa_file-otdat TO file-prevotdat.

    MOVE: wa_file-acact TO file-prevacact.

  ELSE. "no next day record found.

************************************************************************

    file-prevacact = '1'.

********************************************************koonhon*********

 

 

** Text-023 : Error 23 : Previous day record not found.

*    CONCATENATE file-status  text-023 INTO file-status.

*    CONCATENATE file-phpstat text-023 INTO file-phpstat.

**    CONCATENATE file-otsstat text-023 INTO file-otsstat.

*    CONCATENATE file-adsstat text-023 INTO file-adsstat.

  ENDIF. "previous day record

 

 

ENDFORM. "pop_prev_n_next_acact

 

 

 

 

************************************************************************

FORM get_allw_shift_indi USING    currdat     LIKE file-otdat

                                  currtim     LIKE file-sdbtm

 

 

 

 

                         CHANGING sdb_etmindi LIKE file-sdbtmindi.

*

** Convert ddmmyyyy to dd.mm.yyyy

*  CONCATENATE currdat(2) '.'

*              currdat+2(2) '.'

*              currdat+4(4)

*         INTO currdat.

 

 

 

 

** Convert hhmmss to hh:mm:ss

*  CLEAR: currtim_char.

*  CONCATENATE currtim(2) ':'

*              currtim+2(2) ':'

*              currtim+4(2)

*         INTO currtim_char.

 

 

  currtim_int = currtim.

 

 

*   Check if entered time is valid.

  CALL FUNCTION 'CONVERT_TIME_INPUT'

 

 

    EXPORTING

      INPUT                      = currtim_int "char

      PLAUSIBILITY_CHECK         = 'X'

*    IMPORTING

*      OUTPUT                     =

    EXCEPTIONS

      PLAUSIBILITY_CHECK_FAILED  = 1

      WRONG_FORMAT_IN_INPUT      = 2.

 

 

* Exceptions occured for function 'convert_time_input'

  IF sy-subrc <> 0.

 

 

*   Record exception status

    CASE sy-subrc.

      WHEN 01.

        CONCATENATE file-adsstat

        'CONVERT_TIME_INPUT error 01 : PLAUSIBILITY_CHECK_FAILED'

        INTO file-adsstat.

      WHEN 02.

        CONCATENATE file-adsstat

        'CONVERT_TIME_INPUT error 02 : WRONG_FORMAT_IN_INPUT'

        INTO file-adsstat.

    ENDCASE.

 

 

* Time check pass. Continue with obtaining actual shift indicator.

  ELSE.

*   Index of the former time

*   EARLIEST: 0 (datetime2 = datetime1)

*           : 1 (datetime2 > datetime1)

*           : 2 (datetime2 < datetime1)

 

 

*     Compare first datetime set against lower criteria (sdbtm)

    CLEAR: comparison_result1.

    CALL FUNCTION 'L_LL_COMPARE_TIMESTAMPS'

*    CALL FUNCTION 'Z_ZZ_COMPARE_TIMESTAMPS_TEST'  " yap

 

 

      EXPORTING

        DATE_1 = sy-datum "currdat

        TIME_1 = lowtim_0700

*        TIME_1 = lowtim_0659

        DATE_2 = sy-datum "currdat

        TIME_2 = currtim_int "_char

      IMPORTING

        EARLIEST = comparison_result1.

*      EXCEPTIONS

*        INVALID_TIMESTAMP

 

 

*     Compare second datetime set against upper criteria (sdetm)

    CLEAR: comparison_result2.

    CALL FUNCTION 'L_LL_COMPARE_TIMESTAMPS'

*    CALL FUNCTION 'Z_ZZ_COMPARE_TIMESTAMPS_TEST'  " yap

      EXPORTING

        DATE_1 = sy-datum "currdat

        TIME_1 = hitim_1900

        DATE_2 = sy-datum "currdat

        TIME_2 = currtim_int "_char

      IMPORTING

        EARLIEST = comparison_result2.

 

 

    IF sy-subrc = 0.

*       If current time is in between 0700 and 1900

      IF comparison_result1 = 1 AND

         ( comparison_result2 = 2 OR

           comparison_result2 = 0 ).

        sdb_etmindi = 'Day'.

*       If current time is not in between 0700 and 1900

      ELSE.

        sdb_etmindi = 'Night'.

      ENDIF. "current time in between 0700 and 1900

    ENDIF. "sy-subrc = 0 (L_LLCOMPARE_TIMESTAMPS)

  ENDIF. "sy-subrc = 0 (CONVERT_TIME_INPUT)

 

 

ENDFORM. "get_allw_shift_indi

 

 

 

 

 

 

************************************************************************

*KAF

* Form for public holiday check

FORM check_ph.

  DATA:

      counter    TYPE i,

      prevpernr  LIKE file-pernr,

*      prevdtype  LIKE file-mbwtype,

*      prevscact  LIKE file-scact,

*      prevacact  LIKE file-acact,

*      prevextra3 LIKE file-extra3,

      phremarks  LIKE it_daph-phrmks,

      phpaided   LIKE it_daph-phpaid,

      phwtype    LIKE it_daph-phpwtype,

      otmarks    LIKE it_daph-otmarks.

 

 

  phremarks = 'N'.

  phpaided = 'Y'.

  counter = 0.

  phwtype = 6004.

  otmarks = 'Y'.

 

 

  LOOP at file.

    IF file-pernr <> prevpernr.

*      prevdtype = 0.

*      prevscact = 0.

*      prevacact = 0.

*      prevextra3 = 0.

      IF file-mbwtype <> 2.

        phremarks = 'N'.

      ELSE.

        phremarks = 'Y'.

      ENDIF.

    ENDIF.

 

 

    IF file-mbwtype = 2.

      phremarks = 'Y'.

    ENDIF.

 

 

    MOVE:

         file-mbwtype TO it_daph-mbwtype,

         file-pdate TO it_daph-pdate,

         file-pernr TO it_daph-pernr,

         file-otdat TO it_daph-otdat,

         file-scact TO it_daph-scact,

         file-acact TO it_daph-acact,

         file-othrs TO it_daph-othrs,

         file-extra3 TO it_daph-extra3.

 

 

*    it_daph-prvmbwtype = prevdtype.

*    it_daph-prvscact = prevscact.

*    it_daph-prvacact = prevacact.

*    it_daph-prvextra3 = prevextra3.

    it_daph-phrmks = phremarks.

 

 

    IF file-mbwtype = 2.

      IF file-acact = 1 OR file-acact = 2.

        it_daph-phpaid = phpaided.

 

 

      ENDIF.

      IF file-acact = 3 OR file-acact = 4.

        IF file-extra3 = 'CBACKOR'.

          it_daph-phpaid = phpaided.

        ENDIF.

      ENDIF.

    ENDIF.

 

 

    APPEND it_daph.

 

 

    CLEAR it_daph.

 

 

    prevpernr = file-pernr.

*    prevdtype = file-mbwtype.

*    prevscact = file-scact.

*    prevacact = file-acact.

*    prevextra3 = file-extra3.

 

 

  ENDLOOP.

 

 

  LOOP AT it_daph.

    IF it_daph-mbwtype = 2 AND it_daph-phpaid = 'Y'.

      counter = counter + 1.

    ENDIF.

 

 

    IF ( it_daph-mbwtype = 1 OR it_daph-mbwtype = 3 ) AND counter > 0.

      IF it_daph-acact = 5.

        counter = counter - 1.

      ENDIF.

 

 

    ENDIF.

 

 

    IF ( it_daph-mbwtype = 1 OR it_daph-mbwtype = 3 ) AND counter > 0.

      IF it_daph-acact = 3 OR it_daph-acact = 4.

        it_daph-phpwtype = phwtype.

        it_daph-otmarks = otmarks.

        counter = counter - 1.

 

 

        IF it_daph-othrs > 0.

          it_daph-wtype = 6005.

*      MODIFY it_daph.

        ENDIF.

 

 

      ENDIF.

      MODIFY it_daph.

    ENDIF.

  ENDLOOP.

 

 

 

 

  LOOP AT it_daph.

    IF it_daph-otmarks = 'Y'.

      LOOP AT file.

        IF  it_daph-pernr = file-pernr AND it_daph-otdat = file-otdat.

          MOVE:

              it_daph-wtype TO file-wtype,

              it_daph-phpwtype TO file-phpwtype.

          file-phpstat = '-'.

        ENDIF.

        MODIFY file.

      ENDLOOP.

    ENDIF.

 

 

  ENDLOOP.

 

 

ENDFORM.

 

 

Uploading data textfile content

30062014    200114      02062014    2   1   1   00:00   00:00   00:00   00:00   00:00   00:00   00:00   0       PLAN    00:00

30062014    200114      04062014    4   4   4   09:00   00:00   06:00   15:00   06:00   15:00   00:00   0       PLAN    09:00

 

as you can see the spacing between one text to another is min gap


Viewing all articles
Browse latest Browse all 8620

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>