‎2008 Aug 05 11:33 PM
hi all,
i had created a ztable with four fields.
now in module pool when i click the 'create button' the orderdata should be updated in the ztable ( using table control).
The order number should be generated automatically. It should be incremented by1 from the latest order present in the ztable.
below is my code.....
tables zatest.
controls c_zatest type tableview using screen 100.
data : it_zatest type table of zatest,
wa_zatest type zatest.
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
data order type i value 1.
this code is in PAI
when 'CREATE'.
order = order + 1.
wa_zatest-ORDERNO = order.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
append wa_zatest into it_zatest.
endcase.
can u help me with proper code why it is not working
‎2008 Aug 06 12:57 AM
tables zatest.
controls c_zatest type tableview using screen 100.
data : it_zatest type table of zatest,
wa_zatest type zatest.
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
data order type i .
this code is in PAI
when 'CREATE'.
order = order + 1.
wa_zatest-ORDERNO = order.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
append wa_zatest into it_zatest.
clear wa_zatest
try with this
‎2008 Aug 06 5:11 AM
Hi pavan,
Try this,
tables zatest.
controls c_zatest type tableview using screen 100.
data : it_zatest type table of zatest,
wa_zatest type zatest.
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
data : begin of itab occurs 0,
orderno type ztest-orderno,
end of itab.
data v_order type i.
this code is in PAI
when 'CREATE'.
select orderno
from ztest into table itab.
sort itab.
loop at itab.
at last.
move itab-orderno to v_order. '' use the control brk event LAST
endloop.
v_order = v_order + 1.
wa_zatest-ORDERNO = v_order.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
insted of append you need to use insert stmt.
insert wa_zatest into table ztest index sy-tabix.
endcase.
‎2008 Aug 06 5:27 AM
hi,
Yin your code there is nowhere astmt where u retrieve the last order number from your ztable.
if you want to increment the order number next to the last order number in the z table then first you have to get the last order number present in the z table..
try with this. hope it helps...
tables zatest.
controls c_zatest type tableview using screen 100.
data : it_zatest type table of zatest,
wa_zatest type zatest.
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
data order type i value 1.
this code is in PAI
when 'CREATE'.
select max (order number) from ztable into order. " first get the order number from the ztable
order = order + 1.
wa_zatest-ORDERNO = order.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
append wa_zatest into it_zatest.
endcase.
‎2008 Aug 06 5:29 AM
hi,
In your code there is nowhere astmt where u retrieve the last order number from your ztable.
if you want to increment the order number next to the last order number in the z table then first you have to get the last order number present in the z table..
try with this. hope it helps...
tables zatest.
controls c_zatest type tableview using screen 100.
data : it_zatest type table of zatest,
wa_zatest type zatest.
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
data order type i value 1.
this code is in PAI
when 'CREATE'.
select max (order number) from ztable into order. " first get the order number from
the ztable
order = order + 1.
wa_zatest-ORDERNO = order.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
append wa_zatest into it_zatest.
endcase.
‎2008 Aug 06 5:35 AM
Hi,
Kindly check the code below.
I think this would surely work.
And Please reward if helpful.
Thanks.
Declare these globally.
*************************************
data : it_zatest type table of zatest,
wa_zatest type zatest,
wa1_zatest type zatest .
*************************************
data : ok_code type sy-ucomm,
save_ok type sy-ucomm.
Write this code in your PBO.
**********************************
SELECT MAX( ORDERNO ) FROM zatest INTO wa1_zatest-ORDERNO.
wa_zatest-ORDERNO = wa1_zatest-ORDERNO + 1.
**********************************
And this code in PAI
***********************
when 'CREATE'.
wa_zatest-POSNR = ZATEST-POSNR.
wa_zatest-MATNR = ZATEST-MATNR.
wa_zatest-ZMENG = ZATEST-ZMENG.
append wa_zatest into it_zatest.
endcase.
********************
Edited by: AMIT BISHT on Aug 6, 2008 6:36 AM
‎2008 Aug 06 5:39 AM
Hi dear,
Best practice is go to tcode SNRO creat no range there
then fetch latest serial no using enque deque technique.
the present method you are applying will fail if your Modile pool program is used by multiple user's simultaneously.
as there is no locking trechnique available.
Regards,
Gaurav
‎2008 Aug 06 5:40 AM
Hi dear,
Best practice is go to tcode SNRO creat no range there
then fetch latest serial no using enque deque technique.
the present method you are applying will fail if your Modile pool program is used by multiple user's simultaneously.
as there is no locking trechnique available.
Regards,
Gaurav
‎2008 Aug 06 6:25 PM
DATA DECLARATION........
tables:ztest2.
controls: tctrl type tableview using screen 200.
data : it_test type standard table of ztest2,
wa_test type ztest2.
data: order type i value 1.
******PAI*********
when 'CREATE'.
ORDER = ORDER + 1.
wa_test-orderno = order.
wa_test-posnr = ztest2-posnr.
wa_test-matnr = ztest2-matnr.
wa_test-zmeng = ztest2-zmeng.
append wa_test to it_test.
insert into ztest2 values wa_test.
.
when 'BACK'.
LEAVE TO SCREEN 0.
endcase.
ENDMODULE. " USER_COMMAND_0200 INPUT
THEN ALSO IT IS NOT WORKING.PLZ HELP ME.
‎2008 Aug 06 7:57 PM
hi all, thanks its working now.......
now all my condition r satisfied,
but if for 1 ordernumber i want several item number and then should get updated in ztable ,wht is the way for doing that.
for ur reference this is the modified code.
tables:ztest2.
controls: tctrl type tableview using screen 200.
data : it_test type standard table of ztest2,
wa_test type ztest2.
data: order type i value 1.
data: item type ztest2-posnr,
mat type mara-matnr.
case sy-ucomm.
when 'CREATE'.
item = ztest2-posnr mod 10.
if item ne 0.
message e000(zpawan) with 'error'.
endif.
select matnr from mara into mat
where matnr = ztest2-matnr.
if sy-subrc ne 0.
message e001(zpawan) with 'error'.
endif.
endselect.
SELECT MAX( ORDERNO ) FROM ZTEST2 INTO ORDER.
ORDER = ORDER + 1.
wa_test-orderno = order.
wa_test-posnr = ztest2-posnr.
wa_test-matnr = ztest2-matnr.
wa_test-zmeng = ztest2-zmeng.
append wa_test to it_test.
insert into ztest2 values wa_test.
when 'BACK'.
LEAVE TO SCREEN 0.
endcase.
if sy-subrc = 0.
message s002(zpawan) with 'sucess'.
endif.
ENDMODULE. " USER_COMMAND_0200 INPUT