05-21-2016 7:15 AM
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 ?
05-21-2016 8:00 AM
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.
05-21-2016 8:12 AM
thanks firstly fr the reply.
i did so. now iam getting an error that my workarea is not long enough.
05-21-2016 9:14 AM
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
05-21-2016 10:03 AM
05-21-2016 10:09 AM
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
05-21-2016 10:15 AM
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.