Application Development and Automation 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: 
Read only

Insert into Ztable

Former Member
0 Likes
4,337

Hello I have to insert an internal table to ZTable (table of dictionary).

But I don't know why I only can insert one row. Can anyone help me, please?

LOOP AT IT_FICHERO INTO WA_FICHERO.
PERFORM  LOAD.
 PERFORM INSERT_INTO_TABLE.
ENDLOOP.

FORM LOAD.
  ZTABLE-PEDIDO = WA_FICHERO-NUM_PED.
  ZTABLE-SOLICITANTE = WA_FICHERO-SOLIC.
  ZTABLE-FECHA = FECHA.
  ZTABLE-HORA = HORA. 
  ZTABLE-STATUS1 = STATUS_P
  ZTABLE-STATUS2 = STATUS_F. 
ENDFORM.

FORM INSERT_INTO_TABLE.
  INSERT ZTABLE.
    IF SY-SUBRC = 0.
      MESSAGE I005. 
    ELSE.
      MESSAGE I006.
    ENDIF.
ENDFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,401

Hi,

May be the key fields values must be same that is why it is inserting only one row.

Use Insert ZTABLE from <Work Area>.

Reward if it helps,

Satish

7 REPLIES 7
Read only

Former Member
0 Likes
1,401

What are the key fields of ZTABLE?

Rob

Read only

Former Member
0 Likes
1,402

Hi,

May be the key fields values must be same that is why it is inserting only one row.

Use Insert ZTABLE from <Work Area>.

Reward if it helps,

Satish

Read only

0 Likes
1,401

I have defined a new it_table and I have passed all the information inside,

then

insert Ztable from table it_table.

It works well.

Read only

0 Likes
1,401

Hi Ana,

To avoid , collision/ deadlocks while trying to insert / Modify tables,

You have to lock the table before updation and unlock it after the saem.

Refer to my revious post in this thread.

Reward If Useful.

Regards,

Chitra

Read only

Former Member
0 Likes
1,401

Hi Ana ,

Try this.

FORM LOAD.

wa_ZTABLE-PEDIDO = WA_FICHERO-NUM_PED.

wa_ZTABLE-SOLICITANTE = WA_FICHERO-SOLIC.

wa_ZTABLE-FECHA = FECHA.

wa_ZTABLE-HORA = HORA.

wa_ZTABLE-STATUS1 = STATUS_P

wa_ZTABLE-STATUS2 = STATUS_F.

append wa_ztable to ztab.

ENDFORM.

loop at ztab into wa_ztable.

**- Lock the table for updation

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

  • IF sy-subrc <> 0.

  • ENDIF.

**- Updating the values in the afterbilled table.

Insert ztable form table ztab.

COMMIT WORK.

**- Unlock the table after Updation.

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

mode_rstable = 'E'

tabname = 'ZTABLE'.

Reward If Useful.

Regards,

Chitra

Read only

Former Member
0 Likes
1,401

Only the following code will work...

LOOP AT IT_FICHERO INTO WA_FICHERO.

INSERT INTO ZTABLE VALUES WA_FICHERO.

ENDLOOP.

IF YOU DONT WANT LIKE ABOVE.....

LOOP AT IT_FICHERO INTO WA_FICHERO.

PERFORM LOAD.

PERFORM INSERT_INTO_TABLE.

ENDLOOP

FORM LOAD.

ZTABLE-PEDIDO = WA_FICHERO-NUM_PED.

ZTABLE-SOLICITANTE = WA_FICHERO-SOLIC.

ZTABLE-FECHA = FECHA.

ZTABLE-HORA = HORA.

ZTABLE-STATUS1 = STATUS_P

ZTABLE-STATUS2 = STATUS_F.

ENDFORM.

FORM INSERT_INTO_TABLE.

INSERT INTO ZTABLE VALUES WA_FICHERO.

IF SY-SUBRC = 0.

MESSAGE I005.

ELSE.

MESSAGE I006.

ENDIF.

ENDFORM.

Read only

Former Member
0 Likes
1,401

DATA: WA_ZTABLE TYPE ZTABLE.

LOOP AT IT_FICHERO INTO WA_FICHERO.

PERFORM LOAD.

PERFORM INSERT_INTO_TABLE.

CLEAR WA_ZTABLE.

ENDLOOP.

FORM LOAD.

WA_ZTABLE-PEDIDO = WA_FICHERO-NUM_PED.

WA_ZTABLE-SOLICITANTE = WA_FICHERO-SOLIC.

WA_ZTABLE-FECHA = FECHA.

WA_ZTABLE-HORA = HORA.

WA_ZTABLE-STATUS1 = STATUS_P

WA_ZTABLE-STATUS2 = STATUS_F.

ENDFORM.

FORM INSERT_INTO_TABLE.

INSERT INTO ZTABLE VALUE WA_ZTABLE.

IF SY-SUBRC = 0.

MESSAGE I005.

ELSE.

MESSAGE I006.

ENDIF.

ENDFORM.

Message was edited by:

Muthurajan Ramkumar