‎2007 Jun 06 1:55 PM
could anyone plz help in the following problem.there is a table control on which i have fields like serial no and version no. Corresponding to one pack_id, there are many serial no. and coresponding to one serial no there are many versions. my problem is to ensure:
no second version no is generated for a serial no when add button is pressed until previuos one has been saved. in Ztable.(note: serial nos are generated on clicking ADD button and when we select a particular row , version nos are generated.default version no is 1 )
on pressing a history button in change and create mode, only serial no with latest version number should appear in table control. and text of history button should change to 'Recorded Data'.
could anyone help me in this regard..
thanks ®ards
‎2007 Jul 07 12:33 AM
Hi,
<b>ADD : </b>Before generating a new version, select a row from the table ZTABLE with the current key combination(serial no & version no). If sy-subrc = 0, it means that the current version has been saved to the table ZTABLE, so you can generate a new version but if sy-subrc <> 0, it means that the current version has not been saved to ZTABLE, hence dont generate a new version.
<b>HISTORY :</b> Select data from table ZTABLE into an internal table (it_itab). Then, sort the internal table as SORT it_itab serial_no ASCENDING version_no DESCENDING. Then use DELETE ADJACENT DUPLICATES FROM it_itab COMPARING serial_no. Now, your internal table (it_itab) will have serial nos with only current data.
<b>OR</b>
<b>HISTORY :</b>
Use following code.
SELECT serial_no version_no
FROM ztable
INTO TABLE it_itab
ORDER BY serial_no ASCENDING
versio_no DESCENDING.
IF SY-SUBRC = 0.
DELETE ADJACENT DUPLICATES FROM it_itab COMPARING vbeln.
ELSE.
REFRESH it_itab.
ENDIF.
This will give you serial_no with their latest version nos.
Dont hard code the text of the History button. Assign a variable to it. So, by changing the value of the variable, the text can be changed from 'HISTORY' to 'RECORDED DATA'.
Reward points if the answer is helpful.
Regards,
Mukul
Message was edited by:
Mukul
‎2007 Jul 06 1:42 PM
HI sandeep,
need some more clarifications from your side.
1.How you are generating the serial number and version number .
through number range (snro) or + 1 to number of records
2.In display mode do you want to display all packid sno and all versions corresponds to dat?
i can give u one solution with the idea i got from ur post.
1.You can generate the next serial number or version number after checking the ztable .
2.select max(sno) into wrk_sno where productid = '123'.
3.when you are pressing add button increment this wrk_sno.
i can give you proper solution if the specification is proper.
<b>Reward points if the above solution is helpful to you.</b>
‎2007 Jul 07 12:09 AM
hi buddy,
Just check the sy-datar value, which will set if there is any change in the screen field. In your code check sy-datar is initial display the values pulled from database table(which indeed will have the latest data) if sy-datar is set, first update your database table with the values in your screen, then pull the values from database table. Which is going to give the updated data.
Try using some variables for changing the text in your PAI logic. Regards.
‎2007 Jul 07 12:33 AM
Hi,
<b>ADD : </b>Before generating a new version, select a row from the table ZTABLE with the current key combination(serial no & version no). If sy-subrc = 0, it means that the current version has been saved to the table ZTABLE, so you can generate a new version but if sy-subrc <> 0, it means that the current version has not been saved to ZTABLE, hence dont generate a new version.
<b>HISTORY :</b> Select data from table ZTABLE into an internal table (it_itab). Then, sort the internal table as SORT it_itab serial_no ASCENDING version_no DESCENDING. Then use DELETE ADJACENT DUPLICATES FROM it_itab COMPARING serial_no. Now, your internal table (it_itab) will have serial nos with only current data.
<b>OR</b>
<b>HISTORY :</b>
Use following code.
SELECT serial_no version_no
FROM ztable
INTO TABLE it_itab
ORDER BY serial_no ASCENDING
versio_no DESCENDING.
IF SY-SUBRC = 0.
DELETE ADJACENT DUPLICATES FROM it_itab COMPARING vbeln.
ELSE.
REFRESH it_itab.
ENDIF.
This will give you serial_no with their latest version nos.
Dont hard code the text of the History button. Assign a variable to it. So, by changing the value of the variable, the text can be changed from 'HISTORY' to 'RECORDED DATA'.
Reward points if the answer is helpful.
Regards,
Mukul
Message was edited by:
Mukul
‎2007 Jul 13 5:07 AM
thanks a lot for your suggestions. its very help ful...thank you