Application Development 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: 

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

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Can you list the primary keys of the custom table ?

Thanks & Regards,

Navneeth K.

0 Kudos

hello...the primary keys for this table are "mort_ft_id", "mort_kdate" and ", "mandt"

former_member223537
Active Contributor
0 Kudos

Hi,

Instead of INSERT statement try

*INSERT INTO ZRESMORT VALUES E_ZRESMORT.

MODIFY ZRESMORT FROM E_ZRESMORT

Best regards,

Prashant

0 Kudos

hello...i try to insert the coding that you provide just now but it looks like not working as well..