Skip to Content
0
Former Member
Mar 25, 2011 at 07:29 AM

Queries in table maintanance generator

28 Views

Hi,

I have some queries in table maintanance generator. Due to special characters issue i am wrting the code in the screen 1.(Its single screen tbale maintanance ).

My queries are:

1) When i am changing existing record non primary keys primary key value should not change. when i am writing the code it is changing the primary key value also.

2) When i copy the existing record at the time primary key value should be 0 and when i enter the vlaues in non primary keys and i click save button by that time it should generate space id(Primary Key).

My Code:

SELECT SINGLE * FROM zhr9_ob_spacemtr INTO wa_space_mtr

WHERE zob_sbldgid = zhr9_ob_spacemtr-zob_sbldgid AND

zob_sbldname = zhr9_ob_spacemtr-zob_sbldname AND

zob_sbldg = zhr9_ob_spacemtr-zob_sbldg AND

zob_sfloor = zhr9_ob_spacemtr-zob_sfloor AND

zob_srmname = zhr9_ob_spacemtr-zob_srmname AND

zob_squad = zhr9_ob_spacemtr-zob_squad AND

zob_cubenr = zhr9_ob_spacemtr-zob_cubenr AND

zob_dropnr = zhr9_ob_spacemtr-zob_dropnr AND

zob_sarea = zhr9_ob_spacemtr-zob_sarea AND

zob_stype = zhr9_ob_spacemtr-zob_stype AND

zob_tplnr = zhr9_ob_spacemtr-zob_tplnr AND

zob_spaceid NE zhr9_ob_spacemtr-zob_spaceid.

IF sy-subrc = 0.

PERFORM get_spaceid USING c_01 c_object

CHANGING zhr9_ob_spacemtr-zob_spaceid.

MESSAGE e000 WITH 'Entry already exists with the same key'(001).

ELSE.

READ TABLE lt_space_mster INTO wa_space_mtr WITH KEY

zob_sbldgid = zhr9_ob_spacemtr-zob_sbldgid

zob_sbldname = zhr9_ob_spacemtr-zob_sbldname

zob_sbldg = zhr9_ob_spacemtr-zob_sbldg

zob_sfloor = zhr9_ob_spacemtr-zob_sfloor

zob_srmname = zhr9_ob_spacemtr-zob_srmname

zob_squad = zhr9_ob_spacemtr-zob_squad

zob_cubenr = zhr9_ob_spacemtr-zob_cubenr

zob_dropnr = zhr9_ob_spacemtr-zob_dropnr

zob_sarea = zhr9_ob_spacemtr-zob_sarea

zob_stype = zhr9_ob_spacemtr-zob_stype

zob_tplnr = zhr9_ob_spacemtr-zob_tplnr.

IF sy-subrc EQ 0.

PERFORM get_spaceid USING c_01 c_object

CHANGING zhr9_ob_spacemtr-zob_spaceid.

  • lv_error_flag = 'X'.

MESSAGE e000 WITH 'Entry already exists with the same key'(001).

ELSE.

  • IF sy-ucomm = 'KOPE'.

  • CLEAR: zhr9_ob_spacemtr-zob_spaceid.

  • ENDIF.

PERFORM get_spaceid USING c_01 c_object

CHANGING zhr9_ob_spacemtr-zob_spaceid.

APPEND zhr9_ob_spacemtr TO lt_space_mster.

ENDIF.

ENDIF.

Regards,

Maheedhar