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

Function module

Hi everyone!!

I am trying to create a function module that updates data of a table from an internal table. and it gives me a error saying that the Tablename is smaller than the table itself.

If some can help me I will appreciate it.

Here is the code.

FUNCTION Z_SAVE_DATA.

*"----


""Local interface:

*" IMPORTING

*" VALUE(TABLENAME) TYPE SOBJ_NAME

*" TABLES

*" ITTAB

*" EXCEPTIONS

*" DB_ERROR

*" NOT_FOUND

*" WRONG_PARAM

*" INTERNAL_ERROR

*"----


DATA: DBCNT LIKE SY-DBCNT.

UPDATE (TABLENAME) FROM TABLE ITTAB.

IF SY-SUBRC > 0.

RAISE NOT_FOUND.

ENDIF.

CALL 'C_MOD_TABLE' ID 'TABLNAME' FIELD TABLENAME

ID 'ITTAB' FIELD ITTAB-SYS

ID 'FCODE' FIELD 'U'

ID 'DBCNT' FIELD DBCNT.

SET EXTENDED CHECK OFF.

SY-DBCNT = DBCNT.

SET EXTENDED CHECK ON.

CASE SY-SUBRC.

WHEN 0.

WHEN 1.

RAISE DB_ERROR.

WHEN 4.

RAISE NOT_FOUND.

WHEN 8.

RAISE WRONG_PARAM.

WHEN OTHERS.

RAISE INTERNAL_ERROR.

ENDCASE.

ENDFUNCTION.

Thanks in advance.

Fidel Peralta

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jul 15, 2004 at 04:57 PM

    Hi Fidel,

    difficult to tell from here. Set a break point and check in the debugger that the structure in "tablename" matches a line in ittab. It looks to me as if the function module might be called with incorrect parameters.

    Sorry for not being able to help more

    Joerg

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 15, 2004 at 11:01 PM

    Hi!

    One alternative is that you can use some other dynamic operations by defining and creating dynamic data. For much information inspect SAPhelp for "CREATE DATA" and field-symbols.

    Another way is to generate subroutine pools at runtime. For this, refer to the keyword 'GENERATE SUBROUTINE POOL <itab> NAME <name>.'

    It is not exactly about what we talk about but you may like to look at the thread:

    select-from-a-dynamically-chosen-table

    And I think I must remind the warning about "GENERATE ..." statement:

    "This statement is for internal use only.

    Incompatible changes or further developments may occur at any time without warning or notice."

    *--Serdar

    Add a comment
    10|10000 characters needed characters exceeded

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.