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: 

save data to ztable by defining workarea in module pool

Former Member
0 Kudos

Hello.

i want to add data to ztable-zmod . When i give the following input param   : v_matnr, v_date, v_rate, v_qty, v_amt and click on 'SAVE' button data should be updated in the ztable.

  if i want to do this by defining a workarea then to write the code for it ?

6 REPLIES 6

Former Member
0 Kudos

hi,

  define work area same as database table,

move your values to work area.

then,in pai write your code.

case sy-ucomm.

when 'save'.

   modify database table from work area.

endcase.

0 Kudos

thanks firstly fr the reply.

i did so. now iam getting an error that my workarea is not long enough.

sanjaybit
Explorer
0 Kudos

Dear Sanchita,

From your post I understand that you want to save data by combining the input paramaters v_matnr, v_date, v_rate, v_qty and v_amt  to field zmod of table ztable.

Maybe the field length of ZMOD is not equal to the sum of all the fields you are combining.

Try to increase the field length of ZMOD. Just a advice, you may not combine all the fields due to data type mismatch, be careful of using appropriate datatype.


Another approach can be as below.


Pls try to map the input parameters to individual fields of the table and then use modify statement.


DATA: it_ztable       TYPE STANDARD TABLE OF ztable,

       wa_ztable       TYPE ztable.


CLEAR wa_ztable.

wa_ztable-matnr = v_matnr.

wa_ztable-date1 = v_date.

wa_ztable-rate  = v_rate.

wa_ztable-quantity = v_qty.

wa_ztable-amount = v_amt.

MODIFY ztable FROM wa_ztable.

CLEAR wa_ztable.



Thanks,

Sanjay

Former Member
0 Kudos

Hi Sanjay,

zmod is my ztable.

0 Kudos

Hi Sanchita,

Pls paste the code snippet, so that I can try on my system and provide you the feedback.

Meanwhile pls check the data/field lengths of the parameters as well as of the table fields.

Thanks,

Sanjay

0 Kudos

Hi Sanchita,

tables :  zmod

data: wa_mod type   zmod.

data:ok_code type sy-ucomm

Logic in PAI

ok_code = sy-ucomm

case ok_code

when 'SAVE'.

INSERT  ZMOD FROM WA_MOD. "{OR}"

MODIFY ZMOD FROM WA_MOD.

endcase.