cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Start Routine Error

Former Member
0 Kudos

Hi,

I wrote the below in my start routine but getting error while loading data because of the Exporting

EXPORTING

         i_date         = X_DATE

ZDOC_DATE is a Char with DATS

Please let me know how to correct this...

Thanks in advance

DATA : X_DATE LIKE sy-datum.
  CLEAR X_DATE.
  X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
      EXPORTING
         i_date         = X_DATE
         i_periv        = 'X1'
       IMPORTING
         e_buper        = ev_fiscper
         e_gjahr        = ev_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     ev_fiscper2 = ev_fiscper.
     ev_fiscyear2 = ev_fiscyear.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183519
Contributor
0 Kudos

Hi SAP User,

Can u port complete code which you are using in Start routine ?

Are u calling FM 'DATE_TO_PERIOD_CONVERT in LOOP<RESULT_PACKAGE>.. ENDLOOP ?

also, do exception handling.. while you are transferring <SOURCE_FIELDS>-/BIC/ZDOC_DATE TO X_DATE.

ex.

DATA : X_DATE LIKE sy-datum.
  CLEAR X_DATE.

loop at result_package assigning <result_fields>.

  IF <SOURCE_FIELDS>-/BIC/ZDOC_DAT is not initial.


    X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
      EXPORTING
         i_date         = X_DATE
         i_periv        = 'X1'
       IMPORTING
         e_buper        = <result_foelds>-ev_fiscper
         e_gjahr        = <result_foelds>-ev_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     ev_fiscper2 = ev_fiscper.
     ev_fiscyear2 = ev_fiscyear.

endif.

endloop.

Regards,

Hitesh

Former Member
0 Kudos

Thanks all..for your time

The below is the whole start routine..>As this is stopping moving the solution to live...please update me how to correct

DATA : X_DATE LIKE sy-datum.
  CLEAR X_DATE.
  X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = X_DATE
         i_periv        = 'X1'
       IMPORTING
         e_buper        = ev_fiscper
         e_gjahr        = ev_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     ev_fiscper2 = ev_fiscper.
     ev_fiscyear2 = ev_fiscyear.

* Offset one month
     IF ev_fiscper > 1.
       ev_fiscper = ev_fiscper - 1.
     ELSE.
       ev_fiscper = '012'.
       ev_fiscyear = ev_fiscyear - 1.
     ENDIF.


     CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
       EXPORTING
         i_gjahr        = ev_fiscyear
         i_periv        = 'X1'
         i_poper        = ev_fiscper
       IMPORTING
         e_date         = w_last_day
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.


****** Calculate the First day of Period *********
****** This is for the Live Pubs at start of Period count ******

     CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
       EXPORTING
         i_gjahr        = ev_fiscyear2
         i_periv        = 'X1'
         i_poper        = ev_fiscper2
       IMPORTING
         e_date         = w_first_day
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

"    data: counter type i.
"    counter = 7.
"    while counter = 7.
"    endwhile.
***** Count the Live Pubs at the start of the month
     select count(*) into lv_count from /bic/aYREFX_D500
       where /bic/ZDOC_DATE = w_first_day
       and /BIC/ZRESTATU = 'LIVE'
       and usagetype = 1.
****** END Calculate the First day of Period *********
****** END This is for the Live Pubs at start of Period count ******

** We now have the last day of the Last Period stored
** Work out the Max Week
     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = w_last_day
         i_periv        = 'Z1'
       IMPORTING
         e_buper        = ld_poper
         e_gjahr        = ld_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     l_week+0(4) = ld_fiscyear - 1.
     l_week+4(3) = ld_poper.

     maxweek = l_week.

** We now have the last day of the Last Period stored
** Work out the Min Week

     w_last_day = w_last_day - 365.
     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = w_last_day
         i_periv        = 'Z1'
       IMPORTING
         e_buper        = ld_poper
         e_gjahr        = ld_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     l_week+0(4) = ld_fiscyear - 1.
     l_week+4(3) = ld_poper.
     minweek = l_week.


     SELECT REOBJECT /bic/ZLET /BIC/ZFAILURE INTO TABLE it_wkly
         FROM /bic/aYREFX_D800 for all entries in SOURCE_PACKAGE
         WHERE REOBJECT = SOURCE_PACKAGE-REOBJECT
       and /bic/zloadweek > minweek
       and /bic/zloadweek <= maxweek.

Former Member
0 Kudos

We will have the same ZDOC_DATE for all the records in single load....

former_member186445
Active Contributor
0 Kudos

your code needs to be betrween a loop endloop statement as per my previous mail.

Former Member
0 Kudos

Thanks for the update

Modified the code as below,Quick question including it in look..does it have any impact on select statements.

ZDOC_DATE is same for all the reports in the single load


loop at result_package assigning <result_fields>.
CLEAR X_DATE.
  X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = X_DATE
         i_periv        = 'X1'
       IMPORTING
         e_buper        = ev_fiscper
         e_gjahr        = ev_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     ev_fiscper2 = ev_fiscper.
     ev_fiscyear2 = ev_fiscyear.

* Offset one month
     IF ev_fiscper > 1.
       ev_fiscper = ev_fiscper - 1.
     ELSE.
       ev_fiscper = '012'.
       ev_fiscyear = ev_fiscyear - 1.
     ENDIF.


     CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
       EXPORTING
         i_gjahr        = ev_fiscyear
         i_periv        = 'X1'
         i_poper        = ev_fiscper
       IMPORTING
         e_date         = w_last_day
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.


****** Calculate the First day of Period *********
****** This is for the Live Pubs at start of Period count ******

     CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
       EXPORTING
         i_gjahr        = ev_fiscyear2
         i_periv        = 'X1'
         i_poper        = ev_fiscper2
       IMPORTING
         e_date         = w_first_day
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

"    data: counter type i.
"    counter = 7.
"    while counter = 7.
"    endwhile.
***** Count the Live Pubs at the start of the month
     select count(*) into lv_count from /bic/aYREFX_D500
       where /bic/ZDOC_DATE = w_first_day
       and /BIC/ZRESTATU = 'LIVE'
       and usagetype = 1.
****** END Calculate the First day of Period *********
****** END This is for the Live Pubs at start of Period count ******

** We now have the last day of the Last Period stored
** Work out the Max Week
     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = w_last_day
         i_periv        = 'Z1'
       IMPORTING
         e_buper        = ld_poper
         e_gjahr        = ld_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     l_week+0(4) = ld_fiscyear - 1.
     l_week+4(3) = ld_poper.

     maxweek = l_week.

** We now have the last day of the Last Period stored
** Work out the Min Week

     w_last_day = w_last_day - 365.
     CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
         i_date         = w_last_day
         i_periv        = 'Z1'
       IMPORTING
         e_buper        = ld_poper
         e_gjahr        = ld_fiscyear
       EXCEPTIONS
         input_false    = 1
         t009_notfound  = 2
         t009b_notfound = 3
         OTHERS         = 4.

     l_week+0(4) = ld_fiscyear - 1.
     l_week+4(3) = ld_poper.
     minweek = l_week.


     SELECT REOBJECT /bic/ZLET /BIC/ZFAILURE INTO TABLE it_wkly
         FROM /bic/aYREFX_D800 for all entries in SOURCE_PACKAGE
         WHERE REOBJECT = SOURCE_PACKAGE-REOBJECT
       and /bic/zloadweek > minweek
       and /bic/zloadweek <= maxweek.

ENDLOOP

BenedictV
Active Contributor
0 Kudos

It would be a really bad idea/ coding practice to put a SELECT inside a loop. Start packages normally contain ~50,000 records and there will be 50000 hits on the database everytime it goes through the LOOP.

SELECT what you have to select from /bic/aYREFX_D800 and store it in an internal table and use a READ statement on the internal table.

These are some of the basics, so I suggest you get the help of a ABAPer in your team to help you understand these nuances.

Benedict

Former Member
0 Kudos

Hi SAP User,

In your code you are doing Loop on result package and trying to assign it to source fields;

loop at result_package assigning <result_fields>.

CLEAR X_DATE.

  X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


If you are trying to use <source-fields>, then your loop should also be on source_package not on result package.


Also adding 1 to date in char format can cause issues in DATE_TO_PERIOD_CONVERT Fm.


Thanks

Amit

former_member201275
Active Contributor
0 Kudos

Why are you assigning to field symbol <result_fields> and then using another field symbol <SOURCE_FIELDS>?

Do you have an abap person that can help you?

Before you use a field symbol assignment you should also check that it is assigned i.e.

CHECK <SOURCE_FIELDS> IS ASSIGNED.

Answers (2)

Answers (2)

BenedictV
Active Contributor
0 Kudos

Hi,

Check this line,

X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.


You are not assigning any value for <source_fields>. Your start routine contains all source data in packages stored in SOURCE_PACKAGE internal table.

You might want to use,

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

    

     CLEAR X_DATE.

     X_DATE = <SOURCE_FIELDS>-/BIC/ZDOC_DATE + 1.

     <...the rest of your code...>

ENDLOOP.


Benedict

former_member186445
Active Contributor
0 Kudos

what is your exact error message?

Former Member
0 Kudos

Data Load going to dump with the below message

"GETWA_NOT_ASSIGNED"

former_member186445
Active Contributor
0 Kudos

if this is in your start routine, you should have a loop something like

loop at source_package assigning <source_fields>.

blablabla

endloop.