Skip to Content
avatar image
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 comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • 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 comment
    10|10000 characters needed characters exceeded

  • 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 comment
    10|10000 characters needed characters exceeded