Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in the code

Former Member
0 Likes
895

Hey Guys,

I have one question regarding the routine that i have written. This is the routine that i have written:

*&---------------------------------------------------------------------*

*& Include           ZBW_SUPERVISOR_EMP_ALD

*&---------------------------------------------------------------------*

DATA: t_source      TYPE TABLE OF _ty_s_sc_1,

          l_source      TYPE _ty_s_sc_1.

* Save the source data locally

t_source = source_package.

CHECK NOT t_source IS INITIAL.

* Get supervisor details

CLEAR: t_supervisor.

SELECT *

     INTO TABLE t_supervisor

     FROM

     FOR ALL ENTRIES IN t_source

     WHERE employee = t_source-employee

     AND dateto     = '99991231'.

SORT t_supervisor BY employee objvers dateto.

* Check for valid Responsible employee i.e exists in 0employee

* If it does not exist then update 0EMPLOYEE

LOOP AT t_source INTO l_source.

     CLEAR: l_supervisor.

     CHECK l_source-employee IS NOT INITIAL.

     READ TABLE t_employee INTO l_employee

       WITH TABLE KEY employee    = l_source-employee

                      objvers    = 'A'.

     IF sy-subrc = 0.

     

         l_data-supervisor     = l_source-supevisor.

         APPEND l_data TO t_data.

     ENDIF.

ENDLOOP.

SORT t_data BY employee objvers dateto.

DELETE ADJACENT DUPLICATES FROM t_data

     COMPARING employee objvers dateto.

CHECK t_data[] IS NOT INITIAL.

* Attributes to be updated

l_fields-fieldnm = 'SUPERVISOR'.

APPEND l_fields TO t_fields.

l_iobjnm = '0EMPLOYEE'.

*CALL method to update Master Data attributes for OEMPLOYEE InfoObject

CALL METHOD cl_rsdmd_update_master_data=>update_attributes_static

     EXPORTING

       i_iobjnm               = l_iobjnm

       i_t_fields             = t_fields

       i_t_data               = t_data

       i_s_minfo              = l_minfo

       i_monitoring           = rs_c_true

     IMPORTING

       e_subrc                = c_subrc

     CHANGING

       c_t_idocstate          = c_t_idocstate

     EXCEPTIONS

       iobj_not_found         = 1

       generate_program_error = 2

       OTHERS                 = 3.

*Commit for updated 0EMPLOYEE

CALL FUNCTION 'DB_COMMIT'.

source_package = t_source.

Now the error that i m facing is, when i check inside include statement it says there is no main program for this. What all things do i need to define outside the include statement? Can anybody tell me about this?

Thanks,

NSHAH

8 REPLIES 8
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
860

Can you elaborate on your problem a bit?

An Include program (which you have created) is meant to be included in another program (which in turn could be a report or another Include or an FM or a method etc.).

Read only

Former Member
0 Likes
860

The problem is I have this business requirement:

I have 1 cube named ALDCO2A3.  The logic that i need to use in the transformations is go to the table and get the field SUPVISOR by using 0EMPLOYEE and DATETO='12/31/9999' & this i need to populate in the Cube ALDC02A3.

So, for that i wrote an include program in the supervisor which helps me to get 0EMPLOYEE and DATETO. Now, this is the routine that is already given:

PROGRAM trans_routine.

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

*       CLASS routine DEFINITION

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

*

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

CLASS lcl_transform DEFINITION.

  PUBLIC SECTION.

*  Attributs

    DATA:

      p_check_master_data_exist

            TYPE RSODSOCHECKONLY READ-ONLY,

*-    Instance for getting request runtime attributs;

*     Available information: Refer to methods of

*     interface 'if_rsbk_request_admintab_view'

      p_r_request

            TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

  PRIVATE SECTION.

    TYPE-POOLS: rsd, rstr.

*   Rule specific types

    TYPES:

      BEGIN OF _ty_s_SC_1,

*      Field: /BIC/SUPVISOR Supervisor.

        /BIC/SUPVISOR           TYPE N LENGTH 8,

*      Field: RECORD.

        RECORD           TYPE RSARECORD,

      END   OF _ty_s_SC_1.

    TYPES:

      BEGIN OF _ty_s_TG_1,

*      InfoObject: SUPVISOR Supervisor.

        /BIC/SUPVISOR           TYPE /BIC/OISUPVISOR,

      END   OF _ty_s_TG_1.

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

... "insert your code here

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

    METHODS

      compute_SUPVISOR

        IMPORTING

          request                  type rsrequest

          datapackid               type rsdatapid

          SOURCE_FIELDS              type _ty_s_SC_1

        EXPORTING

          RESULT                   type _ty_s_TG_1-/BIC/SUPVISOR

          monitor                  type rstr_ty_t_monitor

        RAISING

          cx_rsrout_abort

          cx_rsrout_skip_record

          cx_rsrout_skip_val.

    METHODS

      invert_SUPVISOR

        IMPORTING

          i_th_fields_outbound         TYPE rstran_t_field_inv

          i_r_selset_outbound          TYPE REF TO cl_rsmds_set

          i_is_main_selection          TYPE rs_bool

          i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set

          i_r_universe_inbound         TYPE REF TO cl_rsmds_universe

        CHANGING

          c_th_fields_inbound          TYPE rstran_t_field_inv

          c_r_selset_inbound           TYPE REF TO cl_rsmds_set

          c_exact                      TYPE rs_bool.

ENDCLASS.                    "routine DEFINITION

*$*$ begin of 2nd part global - insert your code only below this line  *

... "insert your code here

*$*$ end of 2nd part global - insert your code only before this line   *

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

*       CLASS routine IMPLEMENTATION

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

*

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

CLASS lcl_transform IMPLEMENTATION.

  METHOD compute_SUPVISOR.

*   IMPORTING

*     request     type rsrequest

*     datapackid  type rsdatapid

*     SOURCE_FIELDS-/BIC/SUPVISOR TYPE N LENGTH 000008

*    EXPORTING

*      RESULT type _ty_s_TG_1-/BIC/SUPVISOR

    DATA:

      MONITOR_REC    TYPE rsmonitor.

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

... INCLUDE ZBW_SUPERVISOR_EMP_ALD.

*--  fill table "MONITOR" with values of structure "MONITOR_REC"

*-   to make monitor entries

... "to cancel the update process

*    raise exception type CX_RSROUT_ABORT.

... "to skip a record

*    raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

*    raise exception type CX_RSROUT_SKIP_VAL.

     RESULT = .

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

  ENDMETHOD.                    "compute_SUPVISOR

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

*       Method invert_SUPVISOR

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

*

*       This subroutine needs to be implemented only for direct access

*       (for better performance) and for the Report/Report Interface

*       (drill through).

*       The inverse routine should transform a projection and

*       a selection for the target to a projection and a selection

*       for the source, respectively.

*       If the implementation remains empty all fields are filled and

*       all values are selected.

*

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

*

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

  METHOD invert_SUPVISOR.

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

... "insert your code here

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

  ENDMETHOD.                    "invert_SUPVISOR

ENDCLASS.                    "routine IMPLEMENTATION

I included the program ZBW_SUPERVISOR_EMP_ALD in this but the error that comes in the program check is that there is no main program for INCLUDE ZBW_SUPERVISOR_EMP_ALD. My question is i have not defined some fields in this program, so how to define it in this particular routine?

Nihal Shah


Read only

0 Likes
860

Hi Nihal,

  1. It is no problem if an isolated include doesn't compile for itself. Your program trans_routine containing the include statement should compile - this is the important point.
  2. But there are better techniques to insert logic into a given program than includes. Includes are annoying because they have no own context. All the data declared in the include automatically pollute the including program.
    For example, you data t_source, l_source seem to be local to your algorithm. But they are automatically visible in the including code, which is an unwanted side-effect.
    It would be better, for example, to call a method of an own class, having all the necessary data as parameters, and raising all the potential exceptions.

Regards,

Rüdiger

Read only

Former Member
0 Likes
860

Thanks a lot Plantiko for your guidance.

Nihal Shah

Read only

Former Member
0 Likes
860

Hey Plantiko,

I am still getting the issue of the particular field is missing or incomplete. Can you please give me the step by step procedure for how to populate the particular field in the cube by writing routine. I think the routine that i have written is wrong and something is missing. I would appreciate if you could help me in this because i am new to abap and don't know much about writing codes.

Thanks,

NSHAH

Read only

0 Likes
860

Hi Nihal,

it is difficult to make such stuff in a forum. But it could help if you provide the following answers:

  • What is the precise text, word for word please, of the error message you get?
  • When do you get the error message? You are not trying to activate the include alone, but together with the including program? Are you in SE38 of the main program, and there you are hitting "Activate", and in the appearing list of inactive objects you see both objects, the including program as well as the include program? Are you selecting both objects and choose "Activate"? And then you get a syntax error or what?

Regards, Rüdiger

Read only

Former Member
0 Likes
860

Hey Plantiko,

The error that i am getting is "DATETO" field is missing or incomplete. This error i get when i come out of include and execute the main program. Yes i m in the main program, the program is getting activated and then i get the syntax error.

Nihal Shah

Read only

0 Likes
860

Nihal,

the precise error message gives you a line number in the source coude.

Look at that line number.

In that source code line, you will somewhere use a structure or table component DATETO which could not be detected by the compiler.

--> Check the line type of table t_supervisor. Does it contain a component DATETO?

Regards,

Rüdiger