2009 Aug 03 10:32 AM
hi all,
i put matnr no. in screen no. 103
validation is done at that screen only.
now when i want to modify dat record
when i put matnr no. at screen 103
so how i will get all data of dat number to table control screen.
hi all,
i put matnr no. in screen no. 103
validation is done at that screen only.
now when i want to modify dat record
when i put matnr no. at screen 103
so how i will get all data of dat number to table control screen.
2009 Aug 03 10:40 AM
Hi,
You need to write a select query for that.
SELECT *
FROM data_base_table
INTO TABLE itab
WHERE matnr = <field_name>. " the name given for the field in the screen.
IF sy-subrc = 0. " if that matnr exists in the data base table.
<fill the data in the table control>.
ELSE.
MESSAGE 'matnr does not exist' TYPE 'E'.
ENDIF.Thanks,
Sri.
2009 Aug 03 10:48 AM
how to fill data in table control......dats only is my question.
when sy-subrc = 0.
value exist so when i press enter all data from my ztable should come to table control screen.
2009 Aug 03 10:57 AM
Hi,
Use this statement to fill the table control from the internal table.
READ TABLE <internal_table> INTO <table_control_name>.Thanks,
Sri.
2009 Aug 03 10:59 AM
Hi Darshan,
In PAI, write the following code.
PROCESS AFTER OUTPUT
LOOP AT IT_ITAB.
MODULE UPDATE_ITAB.
ENDLOOP.
MODULE USER_COMMAND.
IT_ITAB is the internal table which is having the data.
in UPDATE_ITAB move the values from screen fields to IT_ITAB and append your entries in the internal table. Then in PBO this data will reflect.
In MODULE USER_COMMAND, you have to check the OK_CODE and save the date in the transparent table.Hope this will solve your problem.
Thanks and Regards,
Pavan.
2009 Aug 03 11:16 AM
i used this
READ TABLE it_modify INTO table2 .
but table2 is not same as it_modify so error .
2009 Aug 03 11:20 AM
Hi,
You need to declare the internal table same as that of the database tabel.
DATA it_modify TYPE table2 OCCURS 10.Hope this solves your problem.
Thanks,
Sri.
2009 Aug 03 11:24 AM
hi sri,
values will come to internal table from ztable but how to put values from internal table to table control which i have created.
2009 Aug 03 11:30 AM
Hi,
Suppose if you have
No name marks
in your table control then you have to create an internal table with same structure.
TYPES : BEGIN OF ty_table,
No TYPE I,
name TYPE C,
marks TYPE I,
END OF ty_table.
DATA itab_table TYPE STANDARD TABLE OF ty_table.
Now you use the READ statement to populate the table control from the internal table.
READ TABLE <internal_table> INTO <table_control_name>.Hope it solves your problem.
Thanks,
Sri.
2009 Aug 03 11:33 AM
Hi,
Please check if this is what you want
PROCESS BEFORE OUTPUT.
MODULE STATUS_0130.
LOOP AT T_SKILLDETAILS INTO WA_SKILLDETAILS WITH CONTROL TAB.
MODULE DISPLAY_SKILLDETAILS.
ENDLOOP.
MODULE STATUS_0130 OUTPUT.
SET PF-STATUS 'STATUS'.
* SET TITLEBAR 'xxx'.
IF ( SY-TCODE EQ 'ZEMPLDISPLAY' ).
SELECT EMPID POSNR SKILL EXPR
FROM ZSKIL
INTO CORRESPONDING FIELDS OF TABLE T_SKILLDETAILS
WHERE EMPID EQ ZEMPL-EMPID.
IF SY-SUBRC NE 0.
MESSAGE I004.
ENDIF.
ENDIF.
ENDMODULE.
MODULE DISPLAY_SKILLDETAILS OUTPUT.
IF ( SY-TCODE EQ 'ZEMPLDISPLAY' ).
ZSKIL-EMPID = WA_SKILLDETAILS-EMPID.
ZSKIL-POSNR = WA_SKILLDETAILS-POSNR.
ZSKIL-SKILL = WA_SKILLDETAILS-SKILL.
ZSKIL-EXPR = WA_SKILLDETAILS-EXPR.
ENDIF.
ENDMODULE.
2009 Aug 03 11:38 AM
HI,
PBO
loop at itab with control tc.
module move_itab_to_tc.
endloop.
PAI
loop at itab.
module modify_tab.
endloop.
in Abap Editor
module modify_tab.
describe table itab lines tc-lines.
if tc-lines <= tc-current_line.
modify itab index tc-current_line.
else.
append itab.
endmodule.
module move_itab_to_tc.
move-corresponding itab to your table control on screen.
endmodule.
Hope this is clear to you
2009 Aug 03 11:47 AM
Hi Darshan,
Here is a detailed description of how to update data in table controll.
Updating data in table control
The ABAP language provides two mechanisms for loading the table control with data from the internal table and then storing the altered rows of the table control back to the internal table.
Method 1: Read the internal table into the Table Control in the screenu2019s flow logic. Used when the names of the Table Control fields are based on fields of the internal table.
Method 2: Read the internal table into the Table Control in the module pool code. Used when the names of the Table Control fields are based on fields of the database table.
Method 1 (table control fields = itab fields)
In the flow logic we can read an internal table using the LOOP statement. Define the reference to the relevant able control by specifying WITH CONTROL <ctrl>
Determine which table entry is to be read by specifying CURSOR <ctrl>-CURRENT_LINE.
After the read operation the field contents are placed in the header line of the internal table. If the fields in the table control have the same name as the internal they will be filled automatically. Otherwise we need to write a module to transfer the internal table fields to the screen fields.
We must reflect any changes the user makes to the fields of the table control in the internal table otherwise they will not appear when the screen is redisplayed after PBO processing, (eg, after the user presses Enter or scrolls) However, this processing should be performed only if changes have actually been made to the screen fields of the table control (hence the use of the ON REQUEST)
PROCESS BEFORE OUTPUT.
LOOP AT ITAB_REG WITH CONTROL TCREG
CURSOR TCREG-CURRENT_LINE.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT ITAB_REG.
MODULE MODIFY_ITAB_REG.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.Method 2 (table control fields = dict. fields)
If using a LOOP statement without an internal table in the flow logic, we must read the data in a PBO module which is called each time the loop is processed.
Since, in this case, the system cannot determine the number of internal table entries itself, we must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.
PROCESS BEFORE OUTPUT.
LOOP WITH CONTROL TCREG.
MODULE READ_ITAB_REG.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL TCREG.
CHAIN.
FIELD: ITAB_REG-REG,
ITAB_REG-DESC.
MODULE MODIFY_ITAB_REG
ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE READ_ITAB_REG OUTPUT.
READ TABLE ITAB_REG INDEX TCREG-CURRENT_LINE.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING ITAB_REREG TO TCREG.
ELSE.
EXIT FROM STEP-LOOP.
ENDIF.
ENDMODULE.
MODULE MODIFY_ITAB_REG INPUT.
MOVE-CORRESPONDING TCREG TO ITAB_REG.
MODIFY ITAB_REG INDEX
TCREG-CURRENT_LINE.
ENDMODULE.Updating the internal table
Method 1
PROCESS AFTER INPUT.
LOOP AT ITAB_REG.
CHAIN.
FIELD: ITAB_REG-REG,
ITAB_REG-DESC.
MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
ITAB_REG-MARK = u2018Xu2019.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.Method 2
PROCESS AFTER INPUT.
LOOP WITH CONTROL TCREG.
CHAIN.
FIELD: TCREG-REG,
TCREG-DESC.
MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE MODIFY_ITAB_REG INPUT.
MOVE-CORRESPONDING TCREG TO ITAB_REG.
ITAB_REG-MARK = u2018Xu2019.
MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
ENDMODULE.Updating the database
MODULE USER_COMMAND_100.
CASE OK_CODE.
WHEN u2018SAVEu2019.
LOOP AT ITAB-REG.
CHECK ITAB_REG-MARK = u2018Xu2019.
MOVE-CORRESPONDING ITAB_REG TO TCREG.
UPDATE TCREG.
ENDLOOP.
WHEN u2026
u2026
ENDCASE.
ENDMODULE.Hope this will solve your problem.
Regards,
Pavan.
Edited by: PAVAN CHANDRASEKHAR GANTI on Aug 3, 2009 12:48 PM
2009 Aug 04 6:52 AM
hi pavan,
i have tried both of your methods but still not finding the solution.
i will coppy paste my code here see wat can u do....
when 'MODIFY'.
select * from zmateial into corresponding fields of table it_modify.
call screen 103.
in screen 103.
in pai module i have....
case ok_code.
when 'ENTER'.
matnr1 = mara-matnr.
select matnr from zmateial into table it_m where matnr = matnr1.
if sy-subrc eq 0.
message i002(zdar). " for matnr validation purpose.if exist then it should take other values n display it to screen 105.
else.
call screen 105.
endif.
in screen 105 ....
there is table control of my ztable.
so i want values in dat table control if i put a existing matnr number.
so wat should i do in pai and pbo of screen 105 to get data in table control.
2009 Aug 04 7:02 AM
Hi,
I am not so clear abt your requirement. but to the extent I understood i have modified the code. See this and tell whether it worked or not.
when 'MODIFY'.
select *
from zmateial
into corresponding fields of table it_modify.
call screen 103.in screen 103.
in pai module i have....
case ok_code.
when 'ENTER'.
matnr1 = mara-matnr.
select single matnr
from zmateial
into local_variable
where matnr = matnr1.
if sy-subrc eq 0.
call screen 105. " if exist then it should take other values n display it to screen 105.
else.
MESSAGE 'matnr does not exist' TYPE 'E'.
endif.
Thanks,
Sri.
2009 Aug 04 7:18 AM
hii sri,
case ok_code.
when 'ENTER'.
matnr1 = mara-matnr.
select single matnr
from zmateial
into local_variable
where matnr = matnr1.
if sy-subrc eq 0.
call screen 105. " if exist then it should take other values n display it to screen 105.
else.
MESSAGE 'matnr does not exist' TYPE 'E'.
endif.
when screen 105 will be called values of particular matnr is not coming.
there must be some thing to code in pai and pbo of this screen.
wat should i do in screen 105....?
i tried many things but nothing working...
2009 Aug 04 7:29 AM
Hi,
In PBO of the screen you need to write the code to fetch the data from the internal table and display in the table control.
Firstly you declare the variable globally in TOP INCLUDE and not locally.
In PBO
SELECT *
FROM zmateial
INTO TABLE itab
WHERE matnr = matnr1.
IF sy-subrc = 0.
READ TABLE <internal table> INTO <table control name>.
ENDIF.Hope it helps you.
Thanks,
Sri.
2009 Aug 04 7:43 AM
its giving error dat "TABLE2" cannot be converted to the line type of "ITAB".
2009 Aug 04 7:50 AM
Hi,
As I said earlier you need to declare your internal table same as that of your table control structure.
Suppose if your table control has
eno ename address
then you declare your internal table like
TYPES : BEGIN OF ty_table,
eno TYPE I,
ename TYPE C,
address TYPE C,
END OF ty_line.
DATA internal_table TYPE STANDARD TABLE OF ty_table.
Thanks,
Sri.
2009 Aug 04 8:04 AM
every thing is same...
itab and table 2 are same .....
i have tried this earlier dis was nt working....
2009 Aug 04 9:02 AM
Hi Darshan ,
Just make sure that you had called the table controll in both PAI and PBO like
CONTROLLS: Tabstrip name TYPE TABLEVIEW USING SCREEN screen noIt wont work if you haven't done that. May be that is the reason why it's showing error just check once.
Regards,
Pavan.
2009 Aug 06 6:48 AM
Hi ,
If I am not wrong then you enter the material code and on entering it you want your data to be displayed iin you table control. if I am rigght then reply
2009 Aug 06 6:59 AM
Hi Darshan,
I have seen your coding and if you are using different internal tables for both the table controls of your screen 103 and 105 then where you are calling screen 105 in else statement, before that modify the internal table of screen 105 with the table of screen 103 and then go in screen 105 and put the loop on that table and modify your table control.
i am sure that will work. try, if still not work tell me
2009 Aug 03 10:48 AM
Hi,
Check this. Its similar to your requirement
IF ( SY-TCODE EQ 'ZEMPLDISPLAY' ).
SELECT SINGLE EMPID NAME1 NAME2 STREET1 STREET2 DISTRICT STATE COUNTRY
INTO WA_EMPL1
FROM ZEMPL
WHERE EMPID EQ Z118118EMPL-EMPID.
IF SY-SUBRC EQ 0.
ZEMPL-EMPID = WA_EMPL1-EMPID.
ZEMPL-NAME1 = WA_EMPL1-NAME1.
ZEMPL-NAME2 = WA_EMPL1-NAME2.
ZEMPL-STREET1 = WA_EMPL1-STREET1.
ZEMPL-STREET2 = WA_EMPL1-STREET2.
ZEMPL-DISTRICT = WA_EMPL1-DISTRICT.
ZEMPL-STATE = WA_EMPL1-STATE.
ZEMPL-COUNTRY = WA_EMPL1-COUNTRY.
ENDIF.
ENDIF.
If you have multiple records, use an internal table and populate your screen elements from it.
2009 Aug 03 10:58 AM
by doing dis my data will go to ztable.
i have designed a table control i want data in dat table when i enter matnr no.
if matnr exist it should give all ztable details in my table control screen.
hope i have made u clear.