Skip to Content
author's profile photo Former Member
Former Member

Using FORM ENDFORM in ABAP OO

Hi,

I wrote the code like this .I am trying to use FORM which is defined in Report programm,But I am always getting error

message "Error at parameter 2 ":what change should i do for this. earlier I used the same code in ABAP ( not ABAP OO) it was working.

  • First Programm :

DATA : l_t_OTIFARR TYPE STANDARD TABLE OF /bic/aYO_SID0100,
            w_table_to_be_read(30) type c.

 w_table_to_be_read = '/bic/aYO_SID0100'.
  perform READ_ODS in program YBW1_OTIF__SI_INCLUDES
    tables SOURCE_PACKAGE
           l_t_OTIFARR
           using w_table_to_be_read.

****** REPPORT with FORM Definition

REPORT  YBW1_OTIF__SI_INCLUDES.

FORM READ_ODS
     TABLES SOURCE_PACKAGE structure /BIC/CS8YO_IGORD
            l_t_ODS type TABLE
      USING TABLE_TO_BE_READ TYPE C.

  refresh l_t_ODS.
  select * from (TABLE_TO_BE_READ) into table l_t_ODS
     for all entries in SOURCE_PACKAGE
   where /bic/ynv_order = SOURCE_PACKAGE-/bic/ynv_order.

ENDFORM.

Titled modified and code tags added by: kishan P on Oct 22, 2010 10:47 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Oct 24, 2010 at 11:53 AM

    Hi Mandtha,

    just leave the TYPE TABLE addition:

    FORM READ_ODS
         TABLES SOURCE_PACKAGE structure /BIC/CS8YO_IGORD
                l_t_ODS
          USING TABLE_TO_BE_READ TYPE C.

    TABLES parameters are used to pass references to tables. The only addition that makes sense is 'STRUCTURE'. As you want it generic, just don not use it.

    Or use CHANGING to make it more readable:

    FORM READ_ODS
      USING 
        SOURCE_PACKAGE 
        TABLE_TO_BE_READ TYPE tabname. 
      CHANGING 
        ct_table type TABLE.
      FIELD-SYMBOLS:
        <SOURCE_PACKAGE> TYPE /BIC/CS8YO_IGORD
      ASSIGN SOURCE_PACKAGE to <SOURCE_PACKAGE>.
      refresh ct_table.
      select * from (TABLE_TO_BE_READ) into table ct_table
         for all entries in SOURCE_PACKAGE
       where /bic/ynv_order = <SOURCE_PACKAGE>-/bic/ynv_order.
    ENDFORM.

    Regards,

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 22, 2010 at 05:04 AM

    Hi Mandha,

    I think, FORM parameters

    - without type or

    - of type ANY or

    - of type (ANY) TABLE

    are not possible in OO context.

    You need real types also for tables.

    Try to give the real structure for l_t_ODS and I think it will work!

    Regards,

    Klaus

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      Here I gave l_t_ods of type table , as i want to use the same FORM for reading different table and fill it .table which are read

      will change based on value of w_table_to_be_read.

      Regards

      mandha

  • Posted on Oct 22, 2010 at 07:13 AM

    Hello Mandha

    I have tried testing your coding within a local class and a FORM routine within the same report and it has worked on ECC 6.0.

    Not sure about the context (4.6c? Global class?) in your case.

    What you could do is to write a function module which executes the PERFORM statement. This fm you then call within your method.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

    • I was wrong about the parameters not working. I didn't spot the TYPE keyword.

      I've tested the idea that it's an OO problem, and still can't see that it is. With the following, I get no problem.

      data : l_t_otifarr type standard table of t100,
                  w_table_to_be_read(30) type c.
      
      data: source_package type standard table of t000.
      
      *----------------------------------------------------------------------*
      *       CLASS tst DEFINITION
      *----------------------------------------------------------------------*
      *
      *----------------------------------------------------------------------*
      class tst definition.
        public section.
          class-methods: main.
      endclass.                    "tst DEFINITION
      
      *----------------------------------------------------------------------*
      *       CLASS tst IMPLEMENTATION
      *----------------------------------------------------------------------*
      *
      *----------------------------------------------------------------------*
      class tst implementation.
        method main.
          select * from t100 up to 10 rows into table l_t_otifarr.
      
          w_table_to_be_read = 'T100'.
          perform read_ods in program ymabitest1
            tables source_package
                   l_t_otifarr
                   using w_table_to_be_read.
      
        endmethod.                    "main
      
      endclass.                    "tst IMPLEMENTATION
      
      start-of-selection.
        tst=>main( ).

      YMABITEST1.

      *&---------------------------------------------------------------------*
      *&      Form  READ_ODS
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->SOURCE_PACKAGE    text
      *      -->L_T_ODS           text
      *      -->TABLE_TO_BE_READ  text
      *----------------------------------------------------------------------*
      form read_ods
           tables source_package structure t100
                  l_t_ods type table
            using table_to_be_read type c.
      
      
      
      endform.

      Edited by: Matt on Oct 22, 2010 4:57 PM

  • Posted on Oct 22, 2010 at 03:09 PM

    I suspect your problem may be caused, because in BI 7.0, in start routines, the source_package is defined differently from how it is in BI 3.5.

    In your form, you give SOURCE_PACKAGE as having structure /BIC/CS8YO_IGORD. Verifiy that the fields of /bic/cs8yo_igord exactly match those defined in the start routine.

    matt

    Add a comment
    10|10000 characters needed characters exceeded

    • >

      > The attempt to call the subroutine READ_ODS in the program &PROGRAM& failed due to a type error involving parameter number 2. And i Code the parameter 2 is l_T_OTIFARR.

      >

      > "

      Yes, I know that. There is a possibility, you know, that you've got more than one error! You may well have an issue in any case because you can no longer use the type of the communication structure. ( Which is a big deal when it comes to taking the ABAP out of a routine into a proper ABAP object like a subroutine pool, class or function module ).

      Have you checked and made sure they are EXACTLY the same structure?

      Have you tried my earlier suggestion, changing the parameters of the form, so you have two under USING and one under TABLES.

      It's all very well looking at the proposals and going "oh, it's not that". But have you actually tried? As a developer with over 20 years experience, I can tell you that sometimes the error messages you get are misleading or even entirely wrong. You are attempting to marry object oriented technology with the old external call of forms functionality. I'm not surprised you're having trouble.

      One other tip. Every now and then, restart RSA1, regenerate the transformation and DTP. Sometimes the generation screws up.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.