How to read fields of a structure or Table.
Hi,
I had a requirement where i will send a structure/table name into a Form(Subroutine). This form fills an internal table with all the fields in that structure/table .
Does any one could suggest any programming method to access the field names of structure/table.
Please don't suggest any database tables, as the structures iam going to send need not exist in database.
A quick reply is appreciated.
Thanks in Advance,
Anvitha.
HI Anvitha,
You can use function REUSE_ALV_FIELDCATALOG_MERGE to get the field names and attributes.
REPORT test.
TYPE-POOLS : slis.
DATA : BEGIN OF itab1,
f1 LIKE vbak-vbeln,
f2 LIKE vbap-posnr,
f3 LIKE vbak-netwr,
END OF itab1.
DATA : rep TYPE sy-repid .
DATA : fcat TYPE slis_t_fieldcat_alv.
rep = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = rep
i_internal_tabname = 'ITAB1'
I_STRUCTURE_NAME = 'ITAB1'
i_client_never_display = 'X'
i_inclname = rep
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
the internal table fcat will have field names and attributes of internal table.
Reagrds,
Gagan
Similar Messages
-
How To Read Field Values Form Dynamic Internal Table
Hi,
I Created a dynamic internal table using.
FIELD-SYMBOLS: <gt_table> TYPE STANDARD TABLE,
<wa_gt_table>,
<l_fvalue> TYPE ANY.
This Interanl table is working well, and all values are populated to an ALV.
Now I try to set a link
for that I am using below code
READ TABLE <gt_table> ASSIGNING <l_fvalue> index rs_selfield-tabindex.
IF sy-subrc EQ 0.
insplot = <l_fvalue>-prueflos.
Now it is showing a syntax error :
the data object <l_fvalue> has no structure and there for no component called prueflos
Regards
NausalHi,
Refere following code
Local Field Symbol
FIELD-SYMBOLS: <lf_any> TYPE ANY. "Changed data
LOOP AT <gf_dyna_table> ASSIGNING <gf_dyna>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <gf_dyna> TO <lf_any>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
IF ls_attach-line IS INITIAL.
ls_attach-line = <lf_any>.
ELSE.
CONCATENATE ls_attach-line <lf_any> INTO ls_attach-line
SEPARATED BY lc_tab.
ENDIF.
ENDDO.
CONCATENATE lc_cret ls_attach-line INTO ls_attach-line.
Append Changed Data to attachement table
APPEND ls_attach TO gt_attach.
Clear
CLEAR : ls_attach.
ENDLOOP.
Regards,
Prashant -
How to read field selection in table T004F
How to read field selection(T004F-FAUS1) in table T004F?
it's showing me .---.. etc, how can I know which field it refers to?It looks like a code, I'm not sure, but try TBSL table and match the FAUS1 field to figure out what element does it refer to.
Avraham -
How to add field value to the standard table
Hi,
How to add field value to the standard table?
for example:
when we go to TCODE SE16-> VBAK table -> on the selection screen if we press F4 against VBTYP we get all the available values for that field. How to add a new document Category value to this field so that it shows up in F4 help for that field.Hi Asif,
I don't think it is possible and feasible for adding new field value to the field VBTYP because it is not possible through SPRO.
If u see the domain of this field VBTYP we have fixed values provided by SAP. There is no value table for this. If u have value table then it will be updated through SPRO. But still if u really want to add some value u can do that by getting access key and add the value in the fixed values of the domain. But of no use other than simply displaying in F4. Because for what ever value u created here there will be no documents in VBAK or any table using this domain.
Hope this is clear for u.
Thanks,
Vinod. -
How to update field values in a database table using module pool prg?
hi
how to update field values in a database table using module pool prg?
we created a customized table, and we put 2 push buttons in screen painter update and display.
but update is not working?
data is enter into screen fields and to internal table, but it is not updated in database table.
thanks in adv
vidyaHI,
we already used the update statement. but its not working.
plz check this.
*& Module Pool ZCUST_CALL_REC
PROGRAM ZCUST_CALL_REC.
TABLES: ZCUST_CALL_REC,ZREMARKS.
data: v_kun_low like ZCUST_CALL_REC-kunnr ,
v_kun_high like ZCUST_CALL_REC-kunnr,
v_bud_low like ZCUST_CALL_REC-budat,
v_bud_high like ZCUST_CALL_REC-budat.
ranges r_kunnr for ZCUST_CALL_REC-kunnr .
ranges r_budat for zcust_call_rec-budat.
DATA: ITAB TYPE STANDARD TABLE OF ZCUST_CALL_REC WITH HEADER LINE,
JTAB TYPE STANDARD TABLE OF ZREMARKS WITH HEADER LINE.
*data:begin of itab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of itab.
*data:begin of Jtab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of Jtab.
CONTROLS:vcontrol TYPE TABLEVIEW USING SCREEN '9001'.
CONTROLS:vcontrol1 TYPE TABLEVIEW USING SCREEN '9002'.
*start-of-selection.
*& Module USER_COMMAND_9000 INPUT
text
MODULE USER_COMMAND_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'ENQUIRY'.
perform multiple_selection.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9001'.
WHEN 'UPDATE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
perform update on commit.
WHEN 'DELETE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*& Module STATUS_9000 OUTPUT
text
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE USER_COMMAND_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
endcase.
ENDMODULE. " USER_COMMAND_9001 INPUT
*& Module STATUS_9001 OUTPUT
text
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9002 INPUT
text
module USER_COMMAND_9002 input.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'UPDATE'.
perform move_data.
UPDATE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE UPDATED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT UPDATED'.
ENDIF.
WHEN 'DELETE'.
perform move_data.
DELETE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE DELETED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT DELETED'.
ENDIF.
endcase.
endmodule. " USER_COMMAND_9002 INPUT
*& Module STATUS_9002 OUTPUT
text
module STATUS_9002 output.
SET PF-STATUS 'ZCUSTOMER1'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_9002 OUTPUT
*& Module update_table OUTPUT
text
module update_table output.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
endmodule. " update_table OUTPUT
***Selection Data
FORM SELECT_DATA.
SELECT mandt kunnr budat code remarks FROM zcust_call_rec INTO
table itab
WHERE kunnr IN r_kunnr AND BUDAT IN R_BUDAT.
ENDFORM.
****append vendor code
FORM APPEND_CUSTOMER_CODE.
clear r_kunnr.
clear itab.
clear r_budat.
refresh r_kunnr.
refresh itab.
refresh r_kunnr.
IF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_high
IMPORTING
OUTPUT = r_kunnr-high.
r_kunnr-option = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I003(0) WITH 'ENTER CUSTOMER NUMBER'.
CALL SCREEN '9000'.
ENDIF.
PERFORM V_BUDAT.
ENDIF.
ENDFORM.
FORM V_BUDAT.
IF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'BT'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-HIGH = v_bud_HIGH.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I002(0) WITH 'ENTER POSTING DATE'.
CALL SCREEN '9000'.
r_budat-low = ''.
r_budat-option = ''.
r_budat-sign = ''.
ENDIF.
ENDIF.
ENDFORM.
*& Form update
text
--> p1 text
<-- p2 text
form update .
commit work.
endform. " update
*& Form move_data
text
--> p1 text
<-- p2 text
form move_data .
clear itab.
refresh itab.
move-corresponding zcust_call_rec to itab.
MOVE ZCUST_CALL_REC-MANDT TO ITAB-MANDT.
MOVE ZCUST_CALL_REC-KUNNR TO ITAB-KUNNR.
MOVE ZCUST_CALL_REC-BUDAT TO ITAB-BUDAT.
MOVE ZCUST_CALL_REC-CODE TO ITAB-CODE.
MOVE ZCUST_CALL_REC-REMARKS TO ITAB-REMARKS.
APPEND ITAB.
delete itab where kunnr is initial.
endform. " move_data
thanks in adv
vidya -
How to read the current selection in a table.
Hello Experts,
I've this issue with the web dynpro. I have a Adaptive Webservice Model in web dynpro. And I have three tables in the UI. When a row is selected in the first table, the second table is populated with the appropriate data (using a method in the web service.) the same applies to the third table, when the a row is selected in the second table, the third table has to be populated with the appropriate data. The methods in the web service are all working fine. However, in web dynpro, I am not able to figure out on how I read the selected row in a table. Any information on how to resolve this would be really really helpful.
<
wdContext.currentGetMailElement().setProfileID("-Should be read from the selected row in the table.");
wdThis.wdGetMailControllerController().executeGetMail();
>
regards,
Sam.Hi Samuel,
I didnt clearly understood your problem. When you are selecting a particular row in a table you are executing a web service named Get Mail. Are you passing any input parameter(any selected row data) while executing a web service. And when you get the response node where you have a attribute in the node getmail. Am I right.
If this is the case, then first check if the GetMail node is present or not by comparing it will null or checking its size. If the node is null then you will not get attribute as the element itself is null as nothing is retrieved in response. And if the node is not null then the element at 0th position is selected by default. you can retreieve the attribute by directly using the following code
if(wdContext.nodeGetMail() !=null)
String profileId= wdContext.currentGetMailElement().getProfileID();
Check if this works for you.
Regards,
Ardhendu Sarkar -
How to use FIELD-SYMBOLS to declare a table
How to use FIELD-SYMBOLS to declare a table?
hi yong,
this will be very general:
FIELD-SYMBOLS : <gf_table> TYPE ANY TABLE.
or
to do like a specific table from your program
FIELD-SYMBOLS : <gf_table> TYPE itab.
itab is of course your internal table from your program.
ec -
How Many NUMBER Fields Can SINGLE DATA BASE TABLE CONTAIN
How Many NUMBER Fields Can SINGLE DATA BASE TABLE CONTAIN
Hi
One Database table contain 249 Fields.
Rewards Points if useful..
Regards
Nikunj Shah
Edited by: Nikunj Shah on May 13, 2008 1:08 PM -
How to declare a field in a structure and table
Hi, I have a doubt in declaring a field inside a structure.
types: BEGIN OF mrm_rbkpv.
INCLUDE STRUCTURE rbkp_v.
types: h_rbws LIKE rbws OCCURS 0,
end of mrm_rbkpv.
data : e_rbkp_v type mrm_rbkpv.
Now I want I to refer to field WT_WITHCD inside table H_RBWS.
eg : if e_ebkp_v-h_rbws-wt_withcd = 'X ' is right or wrong??????
POints will rewarded
Thanks in advancehi jaysree,
types: BEGIN OF mrm_rbkpv.
INCLUDE STRUCTURE rbkp_v.
types: h_rbws LIKE rbws OCCURS 0,
end of mrm_rbkpv.
data : e_rbkp_v type mrm_rbkpv.
if e_ebkp_v-h_rbws-wt_withcd = 'X ' - > this will work perfectly.
rgds
anver
if hlped mark points -
How to read the data from an internal table,when column names are known
Hi All
I have a specific requirement. I got an internal table with many fields (let it be my_tab). Some of the fieldnames (column names in internal table my_tab) are stored in separate internal table(let it be my_fields).
I need to store/read data corresponding to the fields (whose name is stored in my_fields) from my_tab.
I am able to build dynamic table (referred by field-symbol) with respect to the given field names in my_fields.
But i am unable to read the data corresponding to the fieldnames from my_tab.
Please provide me some pointer in this regard.
Regards
Swetabh ShuklaHI All
Thanks for the prompt response. I got solution for my question. Please check below thread. For quick reponse i posted my question in one more category. Thanks to all of you.
How to read internal table w.r.t. fieldnames stored in other table -
How to modify field symbol of type Index Table with other field symbol of type any.
Hello Experts,
How is it possible to update an filed symbol table of type Index table with other filed symbol table.
e.g.
Field symbol : <lt_table1> type Index table.
Field symbol : <lt_table2> type Index table.
after some code...at run time these table filled like following.
<lt_tabel1 > has value fore column like c11 , c12 , c13
<lt_table2> has value for column like C11 , C12 , C13 , C14 , C15 . some extra values from <lt_table1>
Now I want to be modify <table1> one entires like C12 with <table2 > col C12.
how I can achieve this.
Regards,
Chetan.Hi,
did you try ASSIGN COMPONENT xx OF STRUCTURE <IT_TABEL1> TO <IT_TABLE2>.
xx will contain the number of the column
or maybe, if you have the description with a field catalog or other, that will be easier ..
regards
Fred -
How to read the data from a sorted table
Hi all,
How to read data from the sorted tables. Please provide some examples.
Thanks and regards,
LisaYou can read like this :
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
INSERT LINE INTO TABLE ITAB.
ENDDO.
CLEAR LINE.
READ TABLE ITAB WITH TABLE KEY COL1 = 3
INTO LINE TRANSPORTING COL2.
WRITE: 'SY-SUBRC =', SY-SUBRC,
/ 'SY-TABIX =', SY-TABIX.
SKIP.
WRITE: / LINE-COL1, LINE-COL2. -
How to remove fields from view V_QCMBSEG for table BSEG
Hi
By mistake have appended 5 fields in standard table BSEG, after that i have deleted that appended structure from table, while deleting from different views network got disconnected i lost connection from server.
So process get terminated and those fields left in view V_QCMBSEG.
Because of this table partially activated.... is there any way to delete it
Thanksits not activating ...its displaying error
Field BSEG-ZZCHANNEL is still being used as a view field in view V_QCMBSEG
Field BSEG-ZZPROD is still being used as a view field in view V_QCMBSEG
Field BSEG-ZZPROJ is still being used as a view field in view V_QCMBSEG
Field BSEG-ZZRECODE is still being used as a view field in view V_QCMBSEG
Field BSEG-ZZSTATE1 is still being used as a view field in view V_QCMBSEG -
How is the field ValStockValue updated in the table S032
Hi,
For a material ValStockValue (S032-WBWBEST) has a negative quantity.
The concerned material has standard price control and there is unrestricted stock.
Could you please let me know how is this field calculated.
Regards
Deepakhave a look into OSS Note 195158 - Copy S032 is updated incorrectly
-
How to read the CSV Files into Database Table
Hi
Friends i have a Table called tblstudent this has the following fields Student ID, StudentName ,Class,Father_Name, Mother_Name.
Now i have a CSV File with 1500 records with all These Fields. Now in my Program there is a need for me to read all these Records into this Table tblstudent.
Note: I have got already 2000 records in the Table tblstudent now i would like to read all these CSV File records into the Table tblstudent.
Please give me some examples to do this
Thank your for your service
Cheers
Jofin1) Read the CSV file line by line using BufferedReader.
2) Convert each line (record) to a List and add it to a parent List. If you know the columns before, you might use a List of DTO's.
3) Finally save the two-dimensional List or the List of DTO's into the datatable using plain JDBC or any kind of ORM (Hibernate and so on).
This article contains some useful code snippets to parse a CSV: http://balusc.xs4all.nl/srv/dev-jep-csv.html
Maybe you are looking for
-
Brand new iMac and I can't access https sites. I'm using the default administrator account so no parental controls are configured. The only thing I've done so far is connected to the internet, changed some personal preferences (desktop picture, doc
-
Empty Objectlist in ABAP Workbench (Trial version) after installation
Hi, In ABAP Workbench/Object Navigator I (BCUSER) don't see the dropdown control (object list). The slot containing the objects is empty and disabled. The system state is after new installation of the Trial version without any problems or errors, no
-
Call search help as seperately
Hello, May I know if there is possible to call the popup window for search help directly, but not through the input field which uses the search help.Thank you very much! Best regards, Shumin
-
How do i know if my computer is 3d ready
i want to find out if i can watch 3d movies on my computer
-
I want to reinstall adobe cs4 on my new laptop, but there is a setup mistake. What could be the problem?