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

Add New Sets of Data when the Function Module is called Several of Times

Hello...I have a function module that I need to add in the new sets of data into the "zresmort" table when the function module is being called several of times. currently, when the function module is being called several of times, the new sets of data will not write into the table. i have a sample coding as below, does anyone know why the problems occured?

FUNCTION Z_MBB_WRITE_RES_MORT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_CKF_CONTRACT) TYPE  /BA1/R2_STR_CALC_KF
*"     REFERENCE(I_CKF_PROCESS) TYPE  /BA1/R2_STR_CKF_PROCESS
*"----------------------------------------------------------------------
TABLES ZRESMORT.

DATA: E_ZRESMORT TYPE STANDARD TABLE OF ZRESMORT WITH HEADER LINE,
      ver_count TYPE /BA1/R0_DTE_JOBVERSION.

ver_count = 1.

DELETE FROM ZRESMORT
    WHERE MORT_KDATE NE I_CKF_PROCESS-TECHNICAL-KEY_DATE.

E_ZRESMORT-MORT_FT_ID  = I_CKF_CONTRACT-COMMON-CONTRACT_ID_EXT.
E_ZRESMORT-MORT_KDATE  = I_CKF_PROCESS-TECHNICAL-KEY_DATE.
E_ZRESMORT-MORT_TSTAMP = I_CKF_PROCESS-TECHNICAL-TIMESTAMP.
E_ZRESMORT-MORT_FLAG   = 1.
E_ZRESMORT-MORT_BUPA   = I_CKF_CONTRACT-BUPA-BUSINESS_PARTNER_ID.
E_ZRESMORT-MORT_PORTFO = I_CKF_CONTRACT-BUPA-PORTFOLIO_CAT.
E_ZRESMORT-MORT_FT_ID_DUM  = I_CKF_CONTRACT-COMMON-CONTRACT_ID.
E_ZRESMORT-MORT_STATUS = ver_count.

*SELECT SINGLE * FROM ZRESMORT.
*IF SY-DBCNT EQ 0.
  INSERT INTO ZRESMORT VALUES E_ZRESMORT.
*ELSE.
*  UPDATE ZRESMORT FROM TABLE E_ZRESMORT.
*  COMMIT WORK.
*ENDIF.

IF SY-SUBRC EQ 0.
ENDIF.

ENDFUNCTION.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 29, 2008 at 11:53 AM

    Hi,

    Can you list the primary keys of the custom table ?

    Thanks & Regards,

    Navneeth K.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 29, 2008 at 11:53 AM

    Hi,

    Instead of INSERT statement try

    *INSERT INTO ZRESMORT VALUES E_ZRESMORT.
    
    MODIFY ZRESMORT FROM E_ZRESMORT

    Best regards,

    Prashant

    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.