Check field symbols plzzz
hiii i'm new to field symbol . can you pleaseee look at the code below and advise if it's ok after append do i need to unassign field symbol like when using work area i need to clear after every append
note: the i_data_file will be use elsewhere
refresh i_data_file.
LOOP AT i_file_upload ASSIGNING <fs_upfile>.
Retrieving the first row of the excel file
IF v_firstrow IS INITIAL.
v_firstrow = <fs_upfile>-row.
ENDIF.
Reset the values for the next row
and inserting each record in table
IF <fs_upfile>-row NE v_firstrow.
APPEND <fs_datafile> TO i_data_file.
v_firstrow = <fs_upfile>-row.
ENDIF.
CASE <fs_upfile>-col.
WHEN 1.
<fs_datafile>-werks = <fs_upfile>-value. "Plant
WHEN 2.
<fs_datafile>-matnr = <fs_upfile>-value. "Company code
WHEN 3.
<fs_datafile>-bwdat = <fs_upfile>-value. "Date
WHEN 4.
<fs_datafile>-losgr = <fs_upfile>-value. "Qty
WHEN 5.
<fs_datafile>-kst003 = <fs_upfile>-value. "Price total
WHEN 6.
<fs_datafile>-kstar = <fs_upfile>-value. "Cost element
WHEN OTHERS.
ENDCASE.
ENDLOOP.
Inserting the last record of the excel file
APPEND <fs_datafile> TO i_data_file.
hi
good
check this link which ll give you detail idea about the field symbol,
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
thanks
mrutyun^
Similar Messages
-
Extended code check Warning : Do not use fields, field symbols globally
Hello,
During extended code check of a program, i get 20 related warnings
Do not use fields, field symbols (GT_UPDTAB) globally
Can be suppressed using pragma ##NEEDED (or pseudo comment "#EC NEEDED)
How can i correct this?
The declaration and usage is as follows :
DATA: BEGIN OF GT_FIELDTAB OCCURS 0.
INCLUDE STRUCTURE DD03P.
INCLUDE STRUCTURE CEFLD.
DATA: END OF GT_FIELDTAB.
GT_FIELDTAB-CONVEXIT = 'ALPHA'.
How can i correct this?
Regards,
RemiHi,
refer this link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
and general declaration if field symbol:
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.
thanks & regards. -
Checking whether field-symbol from another program is assigned?
Hi all
I'm attempting to access a FS from another program.
As the FS can be assigned, or unassigned within that program, how do I checked for that in my calling program?
e.g. calling program;
FIELD-SYMBOLS: <fs> TYPE STANDARD TABLE.
DATA: lv_var(40) type c.
lv_var = '(ZTGT_PROG)<read_fs>'.
ASSIGN (lv_var) TO <fs>. " statement might dump...Hi
Go through this doc and use accordingly
Field Symbols
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Related
ASSIGN, DATA
Additional help
Declaring Field Symbols
Reward points if useful
Regards
Anji -
How check variable in field-symbol?
Hi
I have in my report following code:
data: l_auth_pai type zps_auth_pai,
name(20) type c.
field-symbols: <rep_var> type any.
CONCATENATE 'pai_' l_auth_pai-stru_name into name.
assign (name) TO <rep_var>.
Could You suggest me a way, in which I can check:
1. if in report a variable with name "name' exist/is declared
2.if variable with name "name" is an internal table or a line
Thx in advance
J.S.
Edited by: John Smith on Oct 17, 2008 12:46 PMHi,
data: l_auth_pai type zps_auth_pai,
name(20) type c.
field-symbols: <rep_var> type any.
CONCATENATE 'pai_' l_auth_pai-stru_name into name.
assign (name) TO <rep_var>.
assume that there is a variable pai_matnr and its value is 'TEST'
in your case I assume that l_auth_pai-stru_name contains value 'MATNR'
then statement
assign (name) TO <rep_var>
will cause field-symbol <rep_var> to reference variable pai_matnr
it could be structure or internal table depends on how it is declared.
Regards,
Vishal -
How to check the length of a field symbol value
hi all,
i have a problem with string function, i have assined table fields to a field symbol in a loop i want check the length of the assigned fields symbol value in every loop . i have written like ,,,,,len = strlen( <fs>). then i am getting the length of the field label what i ahve assigned to fiels symbol not the field value lenght ,
please advise me on this,
thanks,
sreI think you're on the right track. This should work:
data: len type i.
data: begin of itab OCCURS 1,
a type string value '1',
b type string value '12',
c type string value '123',
end of itab.
FIELD-SYMBOLS: <fs> type ANY.
do 3 times.
assign component sy-index of STRUCTURE itab to <fs>.
len = strlen( <fs> ).
enddo. -
How to check data type of the field symbol at run time
Hi,
My code is as following:
LOOP AT <fs> ASSIGNING <wa_covp_ext>.
ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
IF sy-subrc = 0.
ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
IF sy-subrc = 0.
SELECT SINGLE sname INTO <f_zzname> FROM pa0001
WHERE pernr = <f_pernr>
AND endda GE sy-datum
AND begda LE sy-datum.
ENDIF.
ENDIF.
ENDLOOP.
This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.check this ...
write describe statement ...
field-symbols : <f_zzname> .
data : sname like pa0001-sname,
typ(10).
assign sname to <f_zzname>.
describe field <f_zzname> type typ.
write : typ. <-- typ contains character type in this case ..
U can check if typ is of character(C) if so .. write the select statement ... -
Field symbols and READ TABLE with system code 4
Hi,
I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
Loop at x_data assign <fs>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
a2 = <c2>.
If sy-subrc = 0.
endif.
I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
Please advise. Thanks
RTHai Rob
Go through the following Code
Field-Symbols are place holders for existing fields.
A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
Field-Symbols are like Pointers in Programming language C .
Syntax check is not effective.
Syntax :
Data : v1(4) value abcd.
Field-symbols <fs>.
Assign v1 to <fs>.
Write:/ <fs>.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
Thanks & regards
Sreenivasulu P -
"Read table" and field symbols
Hello all,
I have a (hopefully simple) question. Let's suppose I want to do the following:
loop at itab1 assigning <fs1>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
if sy-subrc eq 0.
move <fs2>-field1 to ls_out-field1.
endif.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if sy-subrc eq 0.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
It's also possible to do the following instead:
loop at itab1 assigning <fs1>.
unassign: <fs2>,
<fs3>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if <fs2> is assigned.
move <fs2>-field1 to ls_out-field1.
endif.
if <fs3> is assigned.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
My question is: is it "better" to check sy-subrc after each read, and then do a move statement within that if statement, or is it better to check whether the field symbol is assigned each time I want to fill in a field and read everything at the same time?
I'm only really concerned about the case where you don't want to drop out of the loop after the read (so if the read fails you just don't fill any data in). I'm also discounting potential human error (otherwise the sy-subrc method wins hands-down).Just to close this one (albeit somewhat belatedly). I asked Harry Dietz (the ABAP Performance blogging fella) what he would suggest, and he says sy-subrc all the way. Checking that an integer is zero is considerably faster than checking for the assignment, or otherwise, of a field symbol. Furthermore, whilst the field symbol method has the potential to be faster than the sy-subrc method given some compiler optimizations, unfortunately these optimizations don't exist in the ABAP compiler - they're there in the Java compiler though! Shame really. Apparently the ABAP compiler is a pretty simple beast.
Anyway - thanks Harry for clearing this one up! -
Field symbol has not yet been assigned. ???
Dear Experts ,
W hen i tried to execute my program this error appears :
Short text
Field symbol has not yet been assigned.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
You attempted to access an unassigned field symbol
(data segment 32821).
This error may occur if
- You address a typed field symbol before it has been set with
ASSIGN
- You address a field symbol that pointed to the line of an
internal table that was deleted
- You address a field symbol that was previously reset using
UNASSIGN or that pointed to a local field that no
longer exists
- You address a global function interface, although the
respective function module is not active - that is, is
not in the list of active calls. The list of active calls
can be taken from this short dump.
and Here is my CODE :
*& Report ZPO
Report ZPO1.
type-pools slis.
PARAMETERS : PO_Doc like EKBE-EBELN DEFAULT '4800000007'.
PARAMETERS : Plant TYPE WERKS DEFAULT '1000'.
PARAMETERS : PO_ORG TYPE EKORG DEFAULT ''.
data TtlS type mara-wesch .
data TtlH type mara-wesch .
data Ttl type mara-wesch .
data ZEKBE type TABLE OF EKBE.
data ZEKBER type EKBE.
data ZEKPO type TABLE OF EKPO.
data ZEKPOR type EKPO.
data ZEKKOR TYPE EKKO.
data ZNAME1F type LFA1-LIFNR.
data ZWGBEZF TYPE T023T-WGBEZ.
data i type n.
data counter type n.
types : begin of SBAGDS,
Serial Type n, "Purchase Order
EBELN like EKKO-EBELN, "Purchase Order
MATNR like EKPO-MATNR, "Material
TXZ01 like EKPO-TXZ01, "Short Text
MATKL like EKPO-MATKL, "Material Group
WGBEZ like T023T-WGBEZ, "Material Group Desc"
SUBMI like EKKO-SUBMI, "GPM
CHARG like EKBE-CHARG, "Batch
LIFNR like EKKO-LIFNR, "Vendor
NAME1 like LFA1-NAME1, "Vendor Name
RECV like mara-wesch, "Received Quantity
REVR like mara-wesch, "Reversed Quantity
DELV like mara-wesch, "Delivered Quantity
end of SBAGDS .
DATA : BAGDS TYPE SBAGDS OCCURS 0 WITH HEADER LINE.
data Struc like BAGDS.
data: gr_table like BAGDS OCCURS 0 WITH HEADER LINE.
data: gt_fieldcat type slis_t_fieldcat_alv, gt_outtab type SBAGDS occurs 0 with header line.
INITIALIZATION.
i = 0.
counter = 0 .
perform field_cat_init using gt_fieldcat[].
FORM field_cat_init using rt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv,
pos type i value 1.
clear LS_FIELDCAT.
*Column 1
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'Serial'.
ls_fieldcat-SELTEXT_L = 'Serial'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 2
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-SELTEXT_L = 'Purchase Order'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 3
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-SELTEXT_L = 'Material'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 4
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'TXZ01'.
ls_fieldcat-SELTEXT_L = 'Short Text'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 5
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'MATKL'.
ls_fieldcat-SELTEXT_L = 'Material Group'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 6
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'WGBEZ'.
ls_fieldcat-SELTEXT_L = 'Material Group Desc'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 7
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'SUBMI'.
ls_fieldcat-SELTEXT_L = 'GPM'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 8
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'CHARG'.
ls_fieldcat-SELTEXT_L = 'Batch'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 9
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-SELTEXT_L = 'Vendor'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 10
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'NAME1'.
ls_fieldcat-SELTEXT_L = 'Vendor Name'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 11
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'RECV'.
ls_fieldcat-SELTEXT_L = 'Received Quantity'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 12
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'REVR'.
ls_fieldcat-SELTEXT_L = 'Reversed Quantity'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
*Column 13
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'DELV'.
ls_fieldcat-SELTEXT_L = 'Delivered Quantity'.
ls_fieldcat-DDICTXT = 'L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
pos = pos + 1.
endform.
START-OF-SELECTION.
select SINGLE * from EKKO into ZEKKOR where EBELN = PO_DOC.
select SINGLE * from EKPO into ZEKPOR where EBELN = PO_DOC.
select SINGLE NAME1 from LFA1 into ZNAME1F where LIFNR = ZEKKOR-LIFNR.
* ' Buliding Structure
Struc-EBELN = ZEKPOR-EBELN.
Struc-SUBMI = ZEKKOR-SUBMI.
Struc-LIFNR = ZEKKOR-LIFNR.
Struc-Name1 = ZNAME1F.
select * from EKPO into TABLE ZEKPO where EBELN = PO_Doc and WERKS = plant.
LOOP at ZEKPO into ZEKPOR.
select SINGLE WGBEZ from T023T into ZWGBEZF WHERE MATKL = ZEKPOR-MATKL .
counter = counter + 1.
* ' Buliding Structure
Struc-Serial = counter.
Struc-MATNR = ZEKPOR-MATNR.
Struc-TXZ01 = ZEKPOR-TXZ01.
Struc-MATKL = ZEKPOR-MATKL.
Struc-WGBEZ = ZWGBEZF.
* Calcualting Debit transactions from PO History
select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'S'.
LOOP AT ZEKBE INTO ZEKBER.
TtlS = TtlS + ZEKBER-MENGE.
ENDLOOP.
* ' Buliding Structure
Struc-CHARG = ZEKBER-CHARG.
Struc-RECV = TtlS.
Ttl = TtlS.
clear TtlS.
* Calcualting Credit transactions from PO History
select * from EKBE into table ZEKBE where EBELN = PO_Doc and MATNR = ZEKPOR-MATNR and EBELP = ZEKPOR-EBELP and BWART NOT LIKE '' and SHKZG = 'H'.
LOOP AT ZEKBE INTO ZEKBER.
TtlH = TtlH + ZEKBER-MENGE.
ENDLOOP.
* ' Buliding Structure
Struc-REVR = TtlH.
* Calculating Total Delivered
Ttl = Ttl - TtlH.
clear TtlH.
* ' Buliding Structure
Struc-DELV = Ttl.
clear Ttl.
* Writtng ITAB
APPEND Struc to BAGDS.
ENDLOOP.
* Reading ITAB
* WRITE : / , 'ITAB Begin : ' .
* loop at BAGDS into Struc.
* counter = counter + 1.
* write : /,'Serial : ',counter.
* write : / ,'PO : ',Struc-EBELN.
* write : / ,'Vendor : ',Struc-LIFNR.
* write : / ,'Vendor Name : ',Struc-NAME1.
* write : / ,'Material : ',Struc-MATNR.
* write : /,'Short Text: ',Struc-TXZ01.
* write : / ,'Model : ',Struc-MATKL.
* write : / ,'Model Desc : ',Struc-WGBEZ.
* write : /,'GPM : ',Struc-SUBMI.
* write : /,'Lot : ',Struc-CHARG.
* write : /,'Received : ',Struc-RECV.
* write : /,'Reversed : ',Struc-REVR.
* write : /,'Delivered : ',Struc-DELV,/,/,/.
* ENDLOOP.
* Call ALV Grid Viewer
*BREAK-POINT.
gr_Table[] = BAGDS[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SBAGDS'
IT_FIELDCAT = gt_fieldcat[]
TABLES
T_OUTTAB = gr_Table.
Please Advise
Edited by: Sap Sap on Jul 27, 2009 12:18 PM
Edited by: Sap Sap on Jul 27, 2009 12:22 PM
Edited by: Sap Sap on Jul 27, 2009 12:22 PMHi,
The problem seems to be in your ALV grid display.
The reason must be your field catalog.
Just check your fieldcatalog.
The value in the fieldname field of the fieldcatalog should be same as the fieldname in your internal table and should be in capital letters.
Probably you must have mistyped some field.
Kinldy check.
Regards,
Ankur Parab -
Field-symbols v/s Object references in OO-ABAP
Hi,
can anyone please tell me what is the difference between using field-symbols and object references in OO ABAP? Is there a specific need for field-symbols now that we have references?
Thanks.
Shakul.Hi ,
Please note that both Field symbols & Object References are different .
You can use Field symbols during the following situations
1) When you want to modify the value of internal table, the field symbol would be useful since you do not have to use any Modify statement as in case of work area. The Field symbol works as a pointer and any changes to the field symbol will directly affect the value of the internal table
2) Make sure that you do not reassign the field symbol within a Loop iteration
3) Field symbols are useful when you work with dynamic internal tables ( tables whose structure is determined during run time)
4) After Read an internal table ( Read itab...) into a Field symbol, make sure you do a Sy-subrc check or check if the field symbol is assigned.IF not this will give you a run time error
You can use Object References while creating an object to a class. They are instances of a class.
Thanks,
Chakram Govindarajan -
Field symbol has not yet been defined-ALV Grid Display in Report
Hi all,
Iam calling a Function module for ALV grid display in Report programming. Its throwing the Error message Field Symbol has not yet defined. Can any one suggest what i have to do regarding it?Hi,
<li> This is problem with fieldcatalog.
<li> Check field names or table name in small letters in quotes while building fieldcatalog internal table
<li> Check the fieldcatalog internal table , whether it has same fields as in data table which is shown using GRID_DISPLAY function module.
Thanks
Venkat.O -
Dynnamic Field Symbol returning short dump ASSIGN_TYPE_CONFLICT
Hi everyone,
I have a RFC FM and make a dynamic access via SYMBOL FIELD, declared as ANY TABLE. The problem is that sometimes I can get a structure instead of a table and then the error occurs. How do I handle this error if the check IS ASSIGN not work? How do I capture and return an error message?
I tryed this:
FIELD-SYMBOLS: <fs_tabela> TYPE ANY TABLE.
TRY.
ASSIGN (st_b2b_text-tabname) TO <fs_tabela>. <<<<----
DUMP HERE!
CATCH cx_root INTO v_erro.
v_text = v_erro->get_text( ).
MOVE v_text TO st_return-message.
APPEND st_return TO t_return.
PERFORM f_return_error_pi USING event.
ENDTRY.
IF <fs_tabela> IS ASSIGNED.
CONCATENATE 'S' st_b2b_text-tabname INTO vl_wkarea.
CONDENSE vl_wkarea NO-GAPS.
ASSIGN (vl_wkarea) TO <fs_wkarea>.
IF <fs_wkarea> IS ASSIGNED.
LOOP AT <fs_tabela> ASSIGNING <fs_wkarea>.
ASSIGN COMPONENT c_posnr
OF STRUCTURE <fs_wkarea> TO <fs_posnr>.
Does anyone have any tips?
Tnks,
Marco Antonio
from BrazilI solved with this test that I did:
TABLES: vbak.
TYPES: BEGIN OF ty_ctrlimo,
equnr TYPE equnr,
anln1 TYPE anln1,
anln2 TYPE anln2,
aufnr TYPE aufnr,
bukrs TYPE bukrs,
zanln1_andam TYPE anln1,
zanln2_andam TYPE anln2,
END OF ty_ctrlimo.
DATA: estrutura TYPE ty_ctrlimo,
tabela TYPE STANDARD TABLE OF ty_ctrlimo
INITIAL SIZE 0 WITH HEADER LINE,
tabela2 TYPE TABLE OF ty_ctrlimo,
variavel TYPE char30.
DATA: is_tabela.
Evento: START-OF-SELECTION ***
START-OF-SELECTION.
BREAK-POINT.
PERFORM f_check_is_tabela USING 'TABELA' CHANGING is_tabela.
WRITE: / '1 ', 'TABELA =', is_tabela.
SKIP 1.
PERFORM f_check_is_tabela USING 'TABELA2' CHANGING is_tabela.
WRITE: / '2 ', 'TABELA2 =', is_tabela.
SKIP 1.
PERFORM f_check_is_tabela USING 'ESTRUTURA' CHANGING is_tabela.
WRITE: / '3 ', 'ESTRUTURA =', is_tabela.
SKIP 1.
PERFORM f_check_is_tabela USING 'VARIAVEL' CHANGING is_tabela.
WRITE: / '4 ', 'VARIAVEL =', is_tabela.
SKIP 1.
PERFORM f_check_is_tabela USING 'VBAK' CHANGING is_tabela.
WRITE: / '5 ', 'VBAK =', is_tabela.
SKIP 1.
*& Form F_CHECK_IS_TABELA
FORM f_check_is_tabela USING value(p_nome_tabela_estrutura)
CHANGING p_is_tabela.
FIELD-SYMBOLS <check> TYPE ANY.
DATA: lcls_strdscr TYPE REF TO cl_abap_structdescr,
lcls_typdscr TYPE REF TO cl_abap_typedescr.
CLEAR: p_is_tabela.
ASSIGN (p_nome_tabela_estrutura) TO <check>.
lcls_typdscr ?= cl_abap_structdescr=>describe_by_data( <check> ).
IF lcls_typdscr->type_kind = cl_abap_structdescr=>typekind_table.
p_is_tabela = cl_abap_structdescr=>true.
ENDIF.
WRITE: / 'tipo data: ', lcls_typdscr->type_kind.
ENDFORM. " F_CHECK_IS_TABELA -
Field Symbol - Assign type conflict.
Hi, i active successfully my program. This is the code:
DATA ls_g_oref_appl(21) TYPE C.
FIELD-SYMBOLS: <fs_appl> TYPE REF TO cl_ftr_mj_appl.
ls_g_oref_appl = '(SAPLTB4E)g_oref_appl'.
ASSIGN (ls_g_oref_appl) TO <fs_appl>.
But when i execute it, i get a dump with this message:
"ASSIGN_TYPE_CONFLICT : You attempted to assign a field to a typed field symbol,but the field does not have the required type. "
Also, i get sy-subrc = 0, so the field symbol <fs_appl> has a value assign.
Any suggestions? I tried by changing the type of the field to ANY, but it didnt compile.
Thanks for the help,
KarlaHi Daniel, I verified again the type of g_oref_appl, and it is : cl_ftr_mj_appl. I check the top of the include and g_oref_appl is there :
' DATA g_oref_appl TYPE REF TO cl_ftr_mj_appl. '
Hi, Naren, also i tried with the TYPE ANY, but it doesnt compile.
I notice this:
CLASS cl_ftr_mj_appl DEFINITION ABSTRACT.
Is there a problem with field symbols and abstracts class???
Thanks for all your help,
Karla.
Edited by: Karla Tinoco on Mar 5, 2008 11:46 PM -
Field Symbols Assign Type Conflict
Hi,
I am working on a BAdi Implementation and have the following code.
<b>method IF_EX_DPR_ATTRIBUTES~SET_DEFAULTS_UPON_CREATION .
FIELD-SYMBOLS:
<ls_attributes> TYPE dpr_ts_project_ext.
ASSIGN cs_attributes TO <ls_attributes> .
CASE flt_val.
WHEN cl_dpr_co=>sc_ot_project.
<ls_attributes>-extended_attributes-ZZSOL_PRJ_ID = 'C0001'.
ENDCASE.
ENDMETHOD.</b>
This is the sample implementation code provided by SAP. However, when I implement the above code, the system dumps at the statement
<i> ASSIGN cs_attributes TO <ls_attributes> .</i>
and cs_attributes is of type any.
I tried the same code by adding "CASTING" at the end of above line. But, it still gives the dump. Below, is the dump message.
Note
The following error text was processed in the system BS3 : Error in ASSIGN in the program ZCL_IM_DPR_ATTRIBUTES=========CP .
The error occurred on the application server acequad_BS3_30 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Form: IF_EX_DPR_ATTRIBUTES~SET_DEFAULTS_UPON_CREATION of program ZCL_IM_DPR_ATTRIBUTES=========CP
Form: IF_EX_DPR_ATTRIBUTES~SET_DEFAULTS_UPON_CREATION of program CL_EX_DPR_ATTRIBUTES==========CP
Form: ATTRIBUTES_DEFLTS_UPON_ACTION of program CL_DPR_BADI_SERVICES==========CP
Form: ATTRIBUTES_DEFAULTS_UPON_CREA of program CL_DPR_BADI_SERVICES==========CP
Form: SET_DEFAULTS_UPON_CREATION of program CL_DPR_PROJECT================CP
Form: SET_DEFAULTS_UPON_CREATION of program CL_DPR_PROJECT_O==============CP
Form: CONSTRUCTOR of program CL_DPR_PROJECT_O==============CP
Form: IF_DPR_APPL_OBJECT_FACTORY~CREATE_PROJECT of program CL_DPR_APPL_OBJECT_FACTORY====CP
Form: CREATE of program CL_DPR_BSP_APPLICATION========CP
Form: DO_HANDLE_EVENT of program CL_DPR_BSP_C_TOOLS============CP
Any ideas on how to use field symbols in the above context??
Thanks,
RajeshHi Rajesh,
The reason it is dumping is because the actually type of the variable passed in CS_ATTRIBUTES is not fixed this is why they have specified it's type as type any.
The sample code in this regard is not correct, you should fist check the value of FLT_VAL to determine what type of variable CS_ATTRIBUTES actually is.
In the BADI documentation there is a list of values for field FLT_VALUE and the corresponding data type of CS_ATTRIBUTES for that value (According to the documentation the data type for FLT_VAL sc_ot_project is DPR_TS_PROJECT_INT).
method IF_EX_DPR_ATTRIBUTES~SET_DEFAULTS_UPON_CREATION .
FIELD-SYMBOLS:
<ls_attributes> TYPE dpr_ts_project_int.
<i><b>* ASSIGN cs_attributes TO <ls_attributes> .</b></i>
CASE flt_val.
WHEN cl_dpr_co=>sc_ot_project.
<i><b>ASSIGN cs_attributes TO <ls_attributes> .</b></i>
<ls_attributes>-extended_attributes-ZZSOL_PRJ_ID
= 'C0001'.
ENDCASE.
ENDMETHOD.
In this example you will ultimately end up with multiple field symbols for representing the CS_ATTRIBUTES parameter, one field symbol for each filter value you intend handling.
From
De Wildt -
Assign Type conflict with field symbols
I have two tables tab1 & tab2, want to assign field values from tab1 to tab2 suing field symbols. Deatils are :
TYPES: BEGIN OF ty_tab1,
item1 TYPE char20,
item2 TYPE char20,
val1 type i,
val2 type i,
END OF ty_tab1,
BEGIN OF ty_tab2,
item1 TYPE char20,
item2 TYPE char20,
END OF ty_tab2.
DATA: it_tab1 TYPE TABLE OF ty_tab1,
it_tab2 TYPE TABLE OF ty_tab2.
FIELD-SYMBOLS <fs_tab1> TYPE ty_tab1.
<fs_tab2t> type ty_tab2.
LOOP AT it_tab1 assigning <fs_tab1>.
READ TABLE it_tab2 assigning <fs_tab2> WITH KEY item1 = <fs_tab1>-item1
item2 = <fs_tab1>-item2.
IF sy-subrc EQ 0.
ASSIGN COMPONENT 'ITEM1' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
ASSIGN COMPONENT 'ITEM2' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
endif.
endloop.
Getting error msg
You attempted to assign a field to a typed field symbol, but the field does not have the required type.
whats the reason of error.
Edited by: Matt on May 27, 2011 8:59 AM - added tagsTaken from example dump
A new value is to be assigned to the field "...", although this field is
entirely or partly protected against changes.
The following are protected against changes:
- Character literals or numeric literals
- Constants (CONSTANTS)
- Parameters of the category IMPORTING REFERENCE for functions and
methods
- Untyped field symbols not yet assigned a field using ASSIGN
- TABLES parameters if the actual parameter is protected against changes
- USING reference parameters and CHANGING parameters for FORMs, if the
actual parameter is protected against changes and
- Accesses using field symbols if the field assigned using ASSIGN is
protected (or partially protected, e.g. key components of an internal
table with the type SORTED or HASHED TABLE) against changes
- Accesses using references, if the field bound to the reference is
protected (or partially protected) against changes
- External write accesses to READ-ONLY attributes,
- Content of a shared object area instance accessed using a shared lock
(ATTACH_FOR_READ).
You likely fall in one of these cases. Check each and if still unsure please share your code so we can reproduce the error.
Regards
Marcin
Maybe you are looking for
-
Itunes, ID3 tags, & hard drive corruption
My wife is having a strange problem with her iMac, and it’s got me a bit mystified. I’m hoping someone here can shed some light on what might be going on. I apologize in advance for the long post. The problem is that when she plays some songs in iTun
-
Query Help for reporting on last receipt qty
SBO Version: 8.82 PL11 Hello Forum, I am looking for some help devising a command behind a crystal report. We are hoping to achieve the last receipt quantity. To arrive at this we would like it to get the last GRPO for an item and total the quantity
-
TAX code is not working for a specific company code
Hi Friends, One tax code is giving error messa ge that it is not maintained in tax procedure, when iam using the same code for another company code it is working fine. Please help me, points are assured. Thanks. Srini
-
A workflow with the same name already exists.
Hi, whenever I am trying to create a workflow in my MOSS teamroom, I am getting the error "A workflow with the same name already exists". I am getting this error message no matter what name I give. I checked all the lists and document libraries to se
-
I have a question about photoshop elements 11
can i create templates on elements 11 of customize templates of skins on games with elements 11