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

Inserting data into Ztable

Former Member
0 Likes
1,540

Dear All,

Plz tell me how to insert data into ztable through SE38 program.

plz tell me the syntax. It's very urgent.

Looking forward to your earliest response.

Regards,

Gulrez Alam

3 REPLIES 3
Read only

Former Member
0 Likes
614

Hi,

Define an internal table with the type of ztable.

and use below syntax,

********

loop at itab.

insert ztable from itab.

clear itab.

endloop.

*********

Please reward if it is helpful.

Regards,

Bhanu

Read only

Former Member
0 Likes
614

Hi Gulrez ,

there are many approaches to the query

(1) You can use Reports or use module programming

in Se38 you need to create a program which is of type "Executable" for a report or "module pool" for module pool programming

if you are doing report

you need to create a selection screen for user to enter all values on the screen for which ever fields of the Ztable you need to insert....don't forget to create input for all the key fields of the ztable without fail

data : workarea type Ztable.

selection-screen:begin of block b1.

parameters : P_XXXX1 type ZTABLE-FIELDNAME.

parameters : P_XXXX2 type ZTABLE-FIELDNAME.

parameters : P_XXXX3 type ZTABLE-FIELDNAME.

For mandatory fields' add obligatory at the end

parameters : P_XXXX4 type ZTABLE-FIELDNAME obligatory.

selection-screen:end of block b1.

start-of selection.

  • do validation for the fields separately if you need(if they are not mentioned as obligatory on top)

If P_XXXX1 is initial.

Message 'Enter the field' type 'S'.

Exit.

Endif.

*update the table

Fist pass all the fields to a work area

workarea-field1 = p_XXXX1.

workarea-field2 = p_XXXX2.

...

then update the table from workare

MODIFY Ztable FROM workarea.

if sy-subrc = 0.

Message 'Database updated successfully' type 'S'.

else.

Message 'Update Failed' type 'S'.

endif.

This technique is used if you need to insert records 1 by 1

To insert multipe records at the same time you can use modulepool programming with a table control or ALV to fetch user input and save data from user to Ztable

Please refer the sample program code in SE38 for a feel of the same program : "demo_dynpro_tabcont_loop_at"

Pls check and revert if more help is needed

Reward if helpful

Regards

Byju

Read only

Former Member
0 Likes
614

Hello Gulrez,

Where are your data comming from?

If from the presentation server then use

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                         = presentaion file
*   FILETYPE                      = 'ASC'
:
:
* IMPORTING
*   FILELENGTH                  =
*   HEADER                        =
  tables
    data_tab                         = itab == your ztable structure
* EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
:
*   OTHERS                                 = 17
          .

After that simply call

UPDATE ztable FROM TABLE itab.

When you are taking the data from the application server you have to read the records sequentially into your internal table via

OPEN DATASET ...... and READ ....

and then perform the same UPDATE statement as in case of GUI_UPLOAD.

Hope this helps,

Heinz