Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Start routine

Hi experts,

I have a issue in my start routine.

I have data in my source system like follows

Company code----ofiscper--- Posting date--Clearing date

01AB--


0122006---12/5/2006
12/30/2006
--


01AB--


0122006---12/5/2006
NULL
--


01AB--


0122006
12/5/2006

1/15/2007
--


using this data I have to get result folloing using abap start routine

Company code----ofiscper--- Posting dateClearing date-----Zclgdate

01AB--


0122006---12/5/2006
12/30/2006
--


N

01AB--


0122006---12/5/2006
NULL
--


Y

01AB--


0122006
12/5/2007

NULL
--


Y

Where as using following code iam getting all values for Zclgdate 'N'. Can any body please explain whats the wrong with this code.

PROGRAM UPDATE_ROUTINE.

$$ begin of global - insert your declaration only below this line -

  • TABLES: ...

*types: titab1 type /BI0/AFIAP_O0300.

*

*data: itab1 type table of titab1 with header line.

*

*DATA: cstart type titab1-FISCPER,

*cend type titab1-FISCPER,

*ccurrent type titab1-FISCPER.

*

*

*Data: vper type t009b-poper,

  • vyear type t009b-bdatj.

$$ end of global - insert your declaration only before this line -

  • The follow definition is new in the BW3.x

TYPES:

BEGIN OF DATA_PACKAGE_STRUCTURE.

INCLUDE STRUCTURE /BIC/CS80FIAP_O03.

TYPES:

RECNO LIKE sy-tabix,

END OF DATA_PACKAGE_STRUCTURE.

DATA:

DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

FORM startup

TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring

MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n

DATA_PACKAGE STRUCTURE DATA_PACKAGE

USING RECORD_ALL LIKE SY-TABIX

SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS

CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update

*

$$ begin of routine - insert your code only below this line -

  • fill the internal tables "MONITOR" and/or "MONITOR_RECNO",

  • to make monitor entries

DATA: ITAB TYPE table of /BIC/CS80FIAP_O03 with header line,

ITAB_1 TYPE table of /BIC/CS80FIAP_O03 with header line,

ITAB_2 TYPE table of /BIC/CS80FIAP_O03 with header line.

DATA: v_fiscper like ITAB-FISCPER,

loop_curr_fiscper like ITAB-FISCPER.

itab[] = DATA_PACKAGE[].

break-point.

SORT ITAB BY COMP_CODE FISCPER ASCENDING.

READ TABLE ITAB INDEX 1.

if sy-subrc = 0.

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

dAta: v_per type char3,

v_year type char4.

v_year = itab-fiscper+0(4).

v_per = itab-fiscper+4(3).

if v_per = '001'.

v_per = '012'.

v_year = v_year - 1.

concatenate v_year v_per into loop_curr_fiscper.

else.

loop_curr_fiscper = ITAB-FISCPER - 1.

endif.

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

endif.

LOOP AT ITAB.

IF v_fiscper ne ITAB-FISCPER.

V_FISCPER = ITAB-FISCPER.

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

clear: v_per, v_year.

v_year = loop_curr_fiscper+0(4).

v_per = loop_curr_fiscper+4(3).

if v_per = '012'.

v_per = '001'.

v_year = v_year + 1.

concatenate v_year v_per into loop_curr_fiscper.

else.

loop_curr_fiscper = loop_curr_fiscper + 1.

endif.

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

LOOP AT DATA_PACKAGE.

IF DATA_PACKAGE-FISCPER EQ V_FISCPER.

APPEND DATA_PACKAGE TO ITAB_1.

ENDIF.

ENDLOOP.

SORT ITAB_1 BY COMP_CODE FISCPER ASCENDING.

else.

continue.

endif.

LOOP AT ITAB_1.

IF ITAB_1-CLEAR_DATE EQ ''.

ITAB_1-/BIC/ZCLGDATE = 'Y'.

ELSEIF ITAB_1-/BIC/ZFISCPER > loop_curr_fiscper.

ITAB_1-/BIC/ZCLGDATE = 'Y'.

ELSE.

ITAB_1-/BIC/ZCLGDATE = 'N'.

ENDIF.

APPEND ITAB_1 TO ITAB_2.

clear: ITAB_1-/BIC/ZCLGDATE.

ENDLOOP. " loop at itab_1

  • loop_curr_fiscper = loop_curr_fiscper + 1.

ENDLOOP. " loop at itab_2

DATA_PACKAGE[] = ITAB_2[].

*

  • CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

  • EXPORTING

  • I_DATE = sy-datum

    • I_MONMIT = 00

  • I_PERIV = 'K4'

  • IMPORTING

  • E_BUPER = vper

  • E_GJAHR = vyear

    • EXCEPTIONS

    • INPUT_FALSE = 1

    • T009_NOTFOUND = 2

    • T009B_NOTFOUND = 3

    • OTHERS = 4

  • .

  • IF SY-SUBRC <> 0.

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

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

  • ENDIF.

*

*concatenate vyear vper into ccurrent.

*

*vyear = vyear - 1.

*

*concatenate vyear vper into cstart.

*

*vyear = vyear + 2.

*

*concatenate vyear vper into cend.

*

*

*Select * from /BI0/AFIAP_O0300 into table itab1

*where fiscper between cstart and cend.

  • if abort is not equal zero, the update process will be canceled

ABORT = 0.

$$ end of routine - insert your code only before this line -

*

ENDFORM.

Thanks in advance

UC

Former Member
Not what you were looking for? View more on this topic or Ask a question