Finding Dynamic no of Fields
Hi All,
I have a attendance Internal Table of Employees. This internal table is in following format.
Emp ID Date Project Hrs
Now an Employee can have any no of records per day and can book into different no of Project by dividing the no of hrs per day.
Now my requirement is i need to display Output in one line item for each employee for the data in attendance Internal table in the following manner.
EmpID Project1 Hrs1 Project2 Hrs2... ProjectN HrsN.
Here i am facing the problem in finding out the maximum no of Projects as it should be dynamic depending on a particular emp assigned to maximum no of projects.
Please do the needful help..If any Clarification in the Post Plese reply.
Thanks
Shashikanth Naram
Hi Shashikanth,
You can do like this. lets say you have your employee table in this reference lref_emp_tab.
DATA: lref_struct TYPE REF TO cl_abap_structdescr,
lref_emp_tab TYPE REF TO data,
ls_emp_wa TYPE REF TO data,
lv_line TYPE i.
FIELD-SYMBOLS:
<fs_tab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY.
ASSIGN lref_emp_tab->* TO <fs_tab>.
CREATE DATA ls_emp_wa LIKE LINE OF <fs_tab>.
ASSIGN ls_emp_wa->* TO <fs_wa>.
lref_struct ?= cl_abap_typedescr=>describe_by_data( <fs_wa> ).
DESCRIBE TABLE lref_struct->components LINES lv_line.
Now lv_line has number of coloumns in your internal table.
Regards
Abhijeet
Similar Messages
-
Dynamic assign in field symbols
dynamic assign in field symbols
Hi,
DYNAMIC ASSIGN:
If you do not know the name of the field that you want to assign to the field symbol when you write a program, you can use a dynamic ASSIGN statement:
ASSIGN (<f>) TO <FS>.
This statement assigns the field whose name is contained in the field <f> to the field symbol <FS>. You cannot use offset and length in a dynamic ASSIGN.
At runtime, the system searches for the corresponding data object in the following order:
If the ASSIGN statement is in a procedure, the system searches first in its local data.
If it cannot find the object in the local data (or if the ASSIGN statement is not in a procedure), it then looks in the local data of the program.
If the field does not exist in the global data of the program, the system looks in the table work areas declared with the TABLES statement in the main program of the current program group. A program group consists of a main program and all of the programs that are loaded into the same internal session as a result of other program calls.
If the search is successful and a field can be assigned to the field symbol, SY-SUBRC is set to 0. Otherwise, it is set to 4, and the field symbol remains unchanged. For security reasons, you should always check the value of SY-SUBRC after a dynamic ASSIGN to prevent the field symbol pointing to the wrong area.
Searching for the field in this way slows down the program. You should therefore only use the dynamic ASSIGN statement when absolutely necessary. If you know when you create the program that you want to assign a table work area to the field symbol, you can also use the following variant of the dynamic ASSIGN statement:
ASSIGN TABLE FIELD (<f>) TO <FS>.
The system then only searches within the table work areas in the main program of the current program group for the data object that is to be assigned to the field symbol. This addition is forbidden in ABAP Objects, since the latter does not support table work areas.
Suppose we have three programs. The main program:
REPORT demo_field_symbols_dynami_as_1.
TABLES sbook.
sbook-fldate = sy-datum.
PERFORM form1 IN PROGRAM demo_form1.
The other two programs are:
REPORT demo_form1.
FORM form1.
PERFORM form2 IN PROGRAM demo_form2.
ENDFORM.
and
REPORT demo_form2.
FORM form2.
DATA name(20) TYPE c VALUE 'SBOOK-FLDATE'.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN (name) TO <fs>.
IF sy-subrc EQ 0.
WRITE / <fs>.
ENDIF.
ENDFORM.
The output looks something like this:
02.06.1998
The program group in the internal session now consists of the programs DEMO, MYFORMS1 and MYFORMS2. The field symbol <FS> is defined in MYFORMS2. After the dynamic ASSIGN statement, it points to the component FLDATE of the table work area SBOOK declared in the main program DEMO.
REPORT demo_field_symbols_dynami_as_2 .
TABLES sbook.
DATA: name1(20) TYPE c VALUE 'SBOOK-FLDATE',
name2(20) TYPE c VALUE 'NAME1'.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN TABLE FIELD (name1) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
ASSIGN TABLE FIELD (name2) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
The output is:
SY-SUBRC: 0
SY-SUBRC: 4
In the first ASSIGN statement, the system finds the component FLDATE of the table work area SBOOK and SY-SUBRC is set to 0. In the second ASSIGN statement, the system does not find the field NAME1 because it is declared by the DATA statement and not by the TABLES statement. In this case, SY-SUBRC is set to 4.
Reference: http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm
reward points if helpful.
Regards,
Ramya -
How to delete Dynamically created input field UI Element
Hi all,
I want to delete dynamically created input field and label.
Is there any method please tell.
Thanks in advance
HemalathaHi,
In the WDEVENT parameter of the action handler you can find the event id.
***Variables
DATA:
lv_selected type string. "Selected tab value
***Structure and internal table for the Events and messages
DATA:
lt_events type WDR_EVENT_PARAMETER_LIST,
ls_events type WDR_EVENT_PARAMETER.
***Field symbols
field-symbols: <fs_value> type any. "Attribute value in events table
***Move the event table to lt_events
lt_events = wdevent->parameters.
read table lt_events into ls_events with key name = 'SAVE'. "Button Id
if sy-subrc eq 0.
assign ls_events-value->* to <fs_value>.
if sy-subrc eq 0.
lv_selected = <fs_value>.
endif. "IF sy-subrc eq 0.
endif. "IF sy-subrc eq 0.
Regards,
Lekha. -
In Report Painter, need to find out how a field is defined.
I'm trying to find out how a field used in a current report is defined. For example, columns 2-13 are monthly columns. Double clicking on the column name (April), for example, brings up the box "Element Definition: April;$Year. The Value Field is Net Sales. Clicking the drop down box brings up a group of fields, including Net Sales.
The Field Name for Net Sales is MA0001. How do I find out how this field is defined and what accounts are included in it?
Thanks for any help you can give.Hi,
Thank you for your answer. I was able to track 'Net Sales' as a part of a Key Figure Structure and as an element of Key Figure 'Net Sales'. However, when I get into CO-PA, Information System, there is no line for 'Report Components'.
There are the following lines/folders: Display Line Item List, Define Report,Current Settings, Background Processing. I looked at all the possibilities in those line items/folders and nothing was there. Is there another way to get at it?
Thanks again. -
How to get the co-ordinates of a dynamically created input field
Hello Frn's
i have created a dynamic text view . but this text view is not appearing at proper position . I want palce it infront of a dynamically created input field . how can i do this ?
as i am thinking ...i should first of all get info about the co-ordinates of dynamaclly creatd input field . and with respect to these co-ordinates ...set the position of text View .
Please suggest your thoughts .
Thanks and Regards
Priyank DixitHi,
There is no provision in WD for getting screen coordinates and then placing the UI element.
You to add the UI element to layout editor and based on the layout type it will add the UI element to respective position.
I would advice not to create dynamic UI elements( instead you can create them statically and then play with visibility status through context binding ). This will be more effective way and less error prone. This is also recommended practice.
still,For dynamic creation you can refer to following wiki:
http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application
regards
Manas Dua -
How do I find what table a field is in?
Hi,
If I know a field name, how would I search the Data Dictionary to find the table (or tables) that the field is found in?
For example, I have a program spec that that says field AZSUB is in table MARM, but it is not. How can I find what table this field is actualkly in?
Thanks for your help!
AndyHi Andrew,
Just goto se11, enter the data element of that field and clisk on the where used list on the application tool bar. You will get all the tables in which the field appears.
You got find out which would be your appropriate table may be using by the description of the table or the contents or by the links..
Regards,
Vinod Kumar -
How to find out the manditary fields in an IDOC
Hi,
How to find out the manditary fields in an IDOC.
For example MATMAS05 .
For this 2 segments I want to find out the manditary fields.
E1MARA
E1MAKTMHi,
go to transaction WE30 and give the corresponding IDoc type and enter. Then you will get all segments for that IDoc type then double click on segment. A popup box will come in that it will show a check box whether it is a mandatory segment or not. And segment editor button will give all the field details.
Regards -
How to find out Last Changed Fields for a line item of a PO
Dear All,
Pls let me know is there any FM or procedure to find the last changed fields for each line item of a PO. I should be able to get the details on the basis of Last changed Date. Can u pls guide me in this?Hello,
Check the table CDHDR,CDPOS for PO items,
Check this code:
REPORT ZV_GET_LATEST_SO .
DATA: BEGIN OF ITAB OCCURS 0,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
USERNAME TYPE CDHDR-USERNAME,
UDATE TYPE CDHDR-UDATE,
UTIME TYPE CDHDR-UTIME,
TCODE TYPE CDHDR-TCODE,
TABNAME TYPE CDPOS-TABNAME,
TABKEY TYPE CDPOS-TABKEY,
FNAME TYPE CDPOS-FNAME,
CHNGIND TYPE CDPOS-CHNGIND,
END OF ITAB.
TABLES: CDHDR,CDPOS.
DATA: LT_CDHDR LIKE CDHDR OCCURS 0 WITH HEADER LINE,
LT_CDPOS LIKE CDPOS OCCURS 0 WITH HEADER LINE.
*REFRESH AUSG.
CLEAR CDHDR.
CLEAR CDPOS.
CDHDR-OBJECTCLAS = 'EINKBELEG'.
CDHDR-OBJECTID = '0000001784'. " Purchase order number
**SELECT A~OBJECTCLASS A~OBJECTID A~CHANGENR A~USERNAME A~UDATE A~UNAME
**B~TCODE
**B~TABNAME B~TABKEY B~FNAME B~CHNGIND INTO TABLE ITAB FROM CDHDR AS A
**INNER JOIN CDPOS AS B ON A~OBJECTCLASS = B~OBJECTCLASS
** A~OBJECTID = B~OBJECTID
** A~CHANGENR = B~CHANGENR
** WHERE OBJECTCLAS = 'VERKBELEG'
** AND OBJECTID = '0000001784'.
*SELECT * FROM CDPOS INTO TABLE LT_CDPOS WHERE OBJECTCLAS = 'VERKBELEG'
* AND OBJECTID = '0000001784'.
*IF NOT LT_CDPOS[] IS INITIAL.
* SELECT *
* INTO TABLE LT_CDHDR
* FROM CDHDR
* FOR ALL ENTRIES IN LT_CDPOS
* WHERE OBJECTCLAS = LT_CDPOS-OBJECTCLAS
* AND OBJECTID = LT_CDPOS-OBJECTID
* AND CHANGENR = LT_CDPOS-CHANGENR.
*ENDIF.
** SORT ITAB BY OBJECTCLAS ODJECTID DESCENDING.
*LOOP AT ITAB.
* WRITE: ITAB-UDATE."ITAB-UNAME.
*ENDLOOP.
*--- Interne Tabellen -------------------------------------------------
DATA: BEGIN OF ICDSHW OCCURS 50. "Ausgabeaufbereitung
INCLUDE STRUCTURE CDSHW. "Zwischendatei
DATA: END OF ICDSHW.
CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
EXPORTING
DATE_OF_CHANGE = CDHDR-UDATE
OBJECTCLASS = CDHDR-OBJECTCLAS
OBJECTID = CDHDR-OBJECTID
TIME_OF_CHANGE = CDHDR-UTIME
USERNAME = CDHDR-USERNAME
TABLES
I_CDHDR = LT_CDHDR
EXCEPTIONS
NO_POSITION_FOUND = 1
OTHERS = 2.
LOOP AT LT_CDHDR.
CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
EXPORTING
* ARCHIVE_HANDLE = 0
CHANGENUMBER = LT_CDHDR-CHANGENR
* TABLEKEY = '00000000 '
* TABLENAME = ' '
* IMPORTING
* HEADER =
TABLES
EDITPOS = ICDSHW
* EDITPOS_WITH_HEADER =
* EXCEPTIONS
* NO_POSITION_FOUND = 1
* WRONG_ACCESS_TO_ARCHIVE = 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.
LOOP AT ICDSHW.
IF ICDSHW-TABKEY+3(10) = '0000001784'
AND ICDSHW-TABKEY+13(6) = '000001'.
ENDIF.
ENDLOOP.
ENDLOOP.
Vasanth -
Cannot find the Revision Level field in the item details
Hi All,
1) I have created a PR with 2 items in the R/3 Backend using the me51n transaction in which for one of the items i have updated the Revision Level field.
2) To transfer the purchase requisitions created in the above step to the SRM system(sourcing cockpit) i executed the report BBP_EXTREQ_TRANSFER with transaction SE38.
3) Now when i go to the SRM portal and navigate to find the external requirement in the sourcing cockpit, I am not able to find the Revision Level field entered in the backend.
Can some one help.
Regards
SamHi
Please go through this ->
Version Management in R/3
http://help.sap.com/saphelp_47x200/helpdata/en/8a/60b43bb7492147e10000000a114084/frameset.htm
Versioning in SRM
http://help.sap.com/saphelp_srm50/helpdata/en/42/c92d6e3ed16babe10000000a1553f6/frameset.htm
Prerequisites for Version Control in SRM
I) You have activated the version control so that the system creates historical versions.
See the path in the IMG: SRM Server ® Cross-Application Basic Settings ® Switch On Version Control for Purchasing Documents
II) You have set up and activated the workflow for the approval of changes to active purchasing documents. See also: Approval Workflows for Documents and Objects
( Related link -> http://help.sap.com/saphelp_srm50/helpdata/en/5a/af5efc85d011d2b42d006094b92d37/frameset.htm )
Some related SAP OSS Notes ->
Note 1030548 - Revision level in SRM 6.0 connected to ERP 2005
Note 1026021 - EXTREQ interface: Data transfer structures
Note 122105 - ME51, RM06BBI0: Revision level is not filled
Hope this will definitely help.
Regards
- Atul -
To find the date type fields in the row and validate those date fields
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
LAEDA TYPE MARA-LAEDA,
MTART TYPE MARA-MTART,
END OF TY_MARA.
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_mara1 TYPE STANDARD TABLE OF ty_mara,
wa_mara TYPE ty_mara.
loop at it_mara into wa_mara.
describe field wa_mara-ersda type c_data.
if c_data eq 'D'.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = wa_mara-ersda
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2
IF sy-subrc eq 0.
wa_mara-ersda = '00000000'.
append wa_mara to it_mara1.
write :wa_mara-matnr,wa_mara-ersda.
else.
wa_mara-ersda = '00000000'.
append wa_mara to it_mara1.
write :wa_mara-matnr,wa_mara-ersda.
ENDIF.
endif.
endloop.
This issue regarding how to find the date type fields in the row and validate those date fields.If its not a valid date ,i have to assign initial value to that.
I've tried that for single field using describe field.Please help me do that for all fields.Hi Sam,
I believe we had discussed the same issue in the below thread. Can you please refer the below one?
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
If it's not helping you please let us know
Sekar - Our life is short, so help others to grow
Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
you see a reply being an answer to the question of the thread, click "Mark As Answer -
Where do I find dynamic linkmanager on my mac?
where do I find dynamic linkmanager on my mac?
Assuming you get that notorious warning during an attempted install:
Working with your Operating System’s Tools
For anything else you will have to provide more info. Blanket questions about obscure files/ processes out of context are pretty meaningless.
Mylenium -
How to find where the screen field is stored in table
Hi all,
How to find where the screen field is stored in the table .
for some transactions if i press F1 on the field and after checking for the technical help.
I can only find the struture for the screen field, but whereas i need table name for it.
Can anybody help me how to find the table name where the field is stored.
Regards,
MadhaviHi,
Just hitting a F1 on screen field and getting structure name will not help in getting table name.
First you need to know the flow of data in the reqd module, which will help you know all the tables in that module with there most of the fields with the data flow, now you need to work on your own to figure out that in which actual tables that value is stored.
Hope this helps you.
Regards,
Tarun -
Accessing Dynamic Internal table fields
Hello All,
I have one internal table ep_tabx having 138 columns whose data is getting displayed
by using function module reuse_alv_grid_display.
Now my query is, i have created one custom button on the appl toolbar to download ep_tabx data.
IF the user changes the the layout of the output at runtime and then presses that custom button
then i have created one dynamic internal table using call method cl_alv_table_create=>create_dynamic_table suppose <dyn_table> whose struc will be that of
dynamic fieldcatalog returned by using FM REUSE_ALV_GRID_LAYOUT_INFO_GET.
And then I have put a loop on the int table ep_tabx and move corresponding to the int table
<dyn_table>. But when i download the <dyn_table> data through GUI_DOWNLOAD the
date fields data is not getting downloaded correctly. I have 4 date fields in my ep_tabx.
In the alv grid output the date is getting displayed like 08/30/2004(ie mon/date/yr) but in download
file it comes like 20040830(ie yr/mon/date and that too without /).How to access the dynamic
internal tables fields separately so asto convert them in the pgm before the download.
Kindly Help.
Thanks in advance.
MansiHi,
Search in SDN you would get loads of info on accessing dynamic itab's .
in order to convert your date format use WRITE stmt to convert the value in your itab before passing it to download FM.
Regards,
Raghavendra -
Need Help in Field Symbol for Dynamically passing table field value
Hi All,
In my internal table I am having data.
I am dynamically forming table field name and substitute for the another table field name to pass DATA.
but I am getting the Variable name insted of Value ie Data.
I am using Field Symbol for this.
data:
Field-symbols <TS> type any.
field1 type string.
LOOP AT TABLEFIELDS INTO WA_TABLEFIELDS.
READ TABLE TEST WITH KEY NAME = WA_TABLEFIELDS-FIELDNAME.
IF SY-SUBRC = 0.
CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO Field1.
Assign Field1 to <TS>.
ALL_VAL-VALUE = <TS>
"After substituting the <TS> into ALL_VAL-VALUE field I need a DATA to be passed but the variable name is appending"*
APPEND ALL_VAL.
ENDIF.
ENDLOOP.
kindly how to pass the value into the table.
Thanks in advance.
SanHi,
pls assign a break point in
CONCATENATE 'WA_' WA_TABLEFIELDS-TABNAME '-' WA_TABLEFIELDS-FIELDNAME INTO Field1.
Assign Field1 to <TS>.
ALL_VAL-VALUE = <TS>
" Put a break point here and check for the value in <TS>.
if <TS> contains value then create a work area for ALL_VAL AND PASS the Field-Symbol to that and then append thw wa into the table...
Hope this works out!!
thanks -
Coloring of Particular Cells in a dynamic internal table(field symbols)
Hi,
I have a requirement to introduce color into some particular cells in a dynamic internal table(Field symbol) based on some conditions.I know that color can be introduced at cell level in the case of static internal table.But, can anybody tell me whether it is possible to introduce color to particular cells in the dynamic internal table(Field Symbol) .Please suggest me on this issue.
Thanks in advance,
RajeshHi,
This is the sample coding for the colour cell report.
Kindly go through it. It will helps u.
REPORT YMS_COLOURTEST .
DATA: BEGIN OF TP OCCURS 10, ID, NR(8), TEXT(255), END OF TP.
DATA: LENGTH TYPE I VALUE 8, " Length of list
TESTSTRING(15) TYPE C VALUE '012345678901234',
WIDTH TYPE I. " Width of list
DATA: TXT_REPORT LIKE DOKHL-OBJECT.
START-OF-SELECTION.
PERFORM HEADING.
PERFORM OUTPUT_BODY.
FORM HEADING.
FORMAT INTENSIFIED OFF. " Remove any INTENSIFIED
ULINE AT (WIDTH). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED." Title color
WRITE: / SY-VLINE. " Left border
WRITE: 'No |Colour |intensified |intensified off|',
'inverse' NO-GAP.
WRITE: AT WIDTH SY-VLINE. " Right border
ULINE AT (WIDTH). " Line below titles
FORMAT COLOR OFF.
ENDFORM.
FORM OUTPUT_BODY.
DO LENGTH TIMES.
PERFORM WRITE_LINE USING SY-INDEX.
ENDDO.
ENDFORM.
FORM WRITE_LINE USING COUNT TYPE I.
DATA: HELP(14) TYPE C,
COUNT1 TYPE I.
COUNT1 = SY-INDEX - 1.
WRITE: / SY-VLINE NO-GAP.
WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
CASE COUNT1.
WHEN '0'.
HELP = 'COL_BACKGROUND'.
WHEN '1'.
HELP = 'COL_HEADING'.
WHEN '2'.
HELP = 'COL_NORMAL'.
WHEN '3'.
HELP = 'COL_TOTAL'.
WHEN '4'.
HELP = 'COL_KEY'.
WHEN '5'.
HELP = 'COL_POSITIVE'.
WHEN '6'.
HELP = 'COL_NEGATIVE'.
WHEN '7'.
HELP = 'COL_GROUP'.
ENDCASE.
WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
WRITE AT WIDTH SY-VLINE NO-GAP.
ENDFORM.
Thanks,
Shankar
Maybe you are looking for
-
When closing a Word doc can you stop 'Do you want to keep this new document?'
Hi, Everytime I close a Word document I keep getting the save document dialogue box appearing with the text 'Do you want to keep this new document [filename]?You can choose to save your changes, or delete this document immediately. You can't undo thi
-
Infopath support in sharepoint 2013
hi, I heard that infopath will not be supported with SharePoint in the future is that true ? in SharePoint 2013 I can use forms library to submit infopath form to collect data ? Thanks,
-
I have a dell dimension 3000 and comcast cable internet. I installed the linksys wrt54g basically to be able to surf on the couch downstairs away from the dell. The cable modem obviously goes to the router and then ethernet port 1 goes to the Dell.
-
Accessing fastest part of a drive
Hi, I'm inferring from my reading that partitions created at the top of the partition window in disk utility are created at the outer edge of the hard drive and will have faster access (more data passing per r?). I haven't actually seen this spelled
-
Unable to connect Firefox can't establish a connection to the server at www.google.com. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection.