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: 

Problem in class's method

ankur_sharma16
Active Participant
0 Kudos
562

Hello Experts,

I have a problem, i want to create a class (in SE24) through program. In that am having no problem. But the problem coming in how to put the multiple lines of code into method. I can put say single line to the work area and pass it to the FM which will create the method with lines, of that work area or table, as source code.

eg:

     class name = 'ZCLASS1'.

     method name = 'Method1'.

     ls_string = 'NEW-LINE'.

     append ls_string to lt_string.

     Result:

                    Method1

                              NEW-LINE.                        

                    EndMethod1.

So if its a single line, we can do this way. But if we have multiple line of code then how will i pass it ???

<Priority normalized by moderator>

Regards,

Ankur Sharma

Message was edited by: Vinod Kumar

13 REPLIES 13

ankur_sharma16
Active Participant
0 Kudos
522

In simple words, if i dynamically get multiple lines of code then how to put it into internal table ?

0 Kudos
522

Hi,

Do this. Assume you multiple lines of input code is in table input_string.

loop at input_string into ls_input_string.

ls_string = ls_input_string. 

     append ls_string to lt_string.

endloop.

0 Kudos
522

Ankur,

Did you try to write multiple lines in the Method??

You can write any # of lines...

If you want skip multiple lines using your method, then either call the method inside a Do-.. ENDDO for those many times or write a DO .. ENDDO inside your method .. and pass the number of iteration of DO loop as a parameter to your method...

If this is not what you are looking for, please explain your problem in deatil

ankur_sharma16
Active Participant
0 Kudos
522

Hello Harshad Bhingarkar, Thanks for quick reply.

how will i do this:      ls_string =  ' DATA: X TYPE I. '.

                               ls_string =  ' WRITE: 'X'. '.

                                  .

                                  .

                                  .

It will show error.

My only aim is to put pass the code like this to some Itab and pass that Itab to class creation FM.

Hope it gives more help to understand.

Regards,

Ankur Sharma                

0 Kudos
522

in my understanding, you are trying to pass multiple lines to an FM.

probably a table type of string lines.

you can fill the data in string table, and pass the table-type to any FM or methods.

0 Kudos
522

Hello Madhu B,

Thanks Madhu but how will i put the lines in WA ? As shown in above post, if i put lines like that it will show error.

Please suggest.

ankur_sharma16
Active Participant
0 Kudos
522

For eg: i want to put this code in some itab, then how to do it ?

' DATA: BEGIN OF LINE,
        LAND(3)  TYPE C,
        NAME(10) TYPE C,
        AGE      TYPE I,
        WEIGHT   TYPE P DECIMALS 2,
      END OF LINE.

DATA ITAB LIKE SORTED TABLE OF LINE
          WITH NON-UNIQUE KEY LAND NAME AGE WEIGHT. '

0 Kudos
522

Dear,

append into itab and pass this internal table to your FM.

0 Kudos
522

Dear Bharat Rathod ,

i know append, BUT the problem is try to put the code in      ' ... '      and assign it to WA. It will show error.

0 Kudos
522

dear,

please explain what is ' ... ' ?

0 Kudos
522

As mentioned in above post, how will i do this ?

ls_string = ' DATA: LT_STRING TYPE TABLE OF STRING, LT_SOURCE TYPE SEO_METHOD_SOURCE_TABL.

  DATA: LS_ATTR   TYPE LINE OF SEOO_ATTRIBUTES_R, 

LS_METH   TYPE LINE OF SEOO_METHODS_R . . . '

I want to put multiple lines of code into table, for that i need to get this into WA.


    



0 Kudos
522

which fm do you use to create the class?

0 Kudos
522

Hello S. Spronk,

So sorry for such a late reply.

SEO_CLASS_CREATE is FM which will create the class.

You can check the function groups: SEOC, SEOO, SEOQ, SEOD.

Regards,

Ankur Sharma