Sy-tabix & sy-index
hi all,
what is the basic difference between sy-tabix & sy-index
hi shantanu,
SY-TABIX:
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
it can be set by using the following:
1.append
2.collect
3.loop at
4. read
5.search
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.
SY-INDEX:
SY-INDEX is used to describe the number of iteration with in the DO..ENDDO, WHILE ...ENDWHILE....
for example,
DO.
WRITE SY-INDEX.
IF SY-INDEX = 3.
EXIT.
ENDIF.
ENDDO.
it gives output as:
1 2 3
rewards points if useful.
regards,
sandhya
Similar Messages
-
What the Initial value for sy-tabix & sy-index
Hi Folks
I have a small doubt.
What the Initial value for sy-tabix & sy-index?
Can anyone please clarify me?
Regards,
Sreehi sree,
both values are initialized to 0 before processing and after processing values are changed according to used scenarios.
if helpful reward some points.
with regards,
suresh babu aluri. -
Sy-tabix,sy-index,sy-dbcnt
what is the difference between sy-tabix,sy-index,sy-dbcnt explain with example, please.
Hi Murali,
sy-tabix -> the index of internal table
sy-index -> loop counter (used within DO statements to check the no. of times the loop is being executed)
sy-dbcnt -> no. of database lines processed after an open SQL statement
Regards
Nadarajah Pratheb -
ABAP-- diff between sy-sy-tabix and sy-index
Hi Guru's,
Pleae can anybody expalins me what is the difference between sy-tabix and sy-index(Loop Index) ?
Because in one case i am Modifyimg the internal table inside the do loop by giving sy-index ((Index of Internal Tables)(MODIFY scarr_tab INDEX sy-index FROM scarr_wa TRANSPORTING currcode. ) in the syntax and in other case inside loop statement i am modifyng same record by giving sy-tabix MODIFY scarr_tab INDEX sy-tabix FROM scarr_wa TRANSPORTING currcode.) in the syntax.
in both cases its working fine but i am not getting which one i have to use where to modify the internal table?
regards
SATYAHi Henry,
SY-INDEX is the value of the current iteration. It is applicable for the following programming constructs in ABAP -
DO...ENDDO.
WHILE...ENDWHILE.
SY-TABIX (TABle IndeX) is applicable to internal tables. If you scroll down in the link which Eddie has given, you will find a more detailed explanation for sy-tabix and which statements affect its value.
Regards,
Anand Mandalika. -
What is difference between sy-index and sy-tabix and where both are using ?
what is difference between sy-index and sy-tabix and where both are using ?
hi nagaraju
sy-tabix is in Internal table, current line index. So it can only be used while looping at the internal table.
sy-index is in Loops, number of current pass. This you can use in other loop statements also (like do-enddo loop, while-endwhile)
SY-INDEX is a counter for following loops: do...enddo, while..endwhile
SY-TABIX is a counter for LOOP...ENDLOOP, READ TABLE...
Here is an example from which you can understand the difference between sy-tabix and sy-index.
Itab is an internal table with the following data in it.
id Name
198 XYZ
475 ABC
545 PQR.
loop at itab where id > 300.
write :/ itab-id, itab-name , sy-tabix, sy-index.
endloop.
My output will be :
475 ABC 2 1
545 PQR 3 2
Sy-tabix is the index of the record in internal table.
sy-index gives the no of times of loop passes.
So, for the first record in the output (475 ABC), 2 is the index of the record in internal table and as it is first time loop pass occured, sy-index value is 1.
Regards,
navjot
award points -
Sy-tabix in relation to LOOP AT and READ TABLE
Hi All,
As per SAP documentation,
1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
But what happens when READ TABLE is used while looping through another internal table?
i.e. Loop at TAB1...
write sy-tabix.
READ TABLE TAB2...
write sy-tabix.
endloop.
If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
Thanks,
JaganHi
If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
After READ TABLE TAB2 try to check the SY-SUBRC:
LOOP AT TAB1.
WRITE: / 'TAB1 index:', SY-TABIX.
READ TABLE TAB2 .........
IF SY-SUBRC = 0.
WRITE: 'TAB2 index:', SY-TABIX.
Try this:
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
FIELD1,
END OF ITAB2.
DATA: INDEX TYPE I.
DO 10 TIMES.
APPEND ITAB.
ENDDO.
DO 10 TIMES.
APPEND ITAB2.
ENDDO.
LOOP AT ITAB.
WRITE: / 'ITAB:', SY-TABIX.
INDEX = SY-TABIX + 2.
READ TABLE ITAB2 INDEX INDEX.
IF SY-SUBRC = 0.
WRITE: 'ITAB2:', SY-TABIX.
ENDIF.
ENDLOOP.
Max -
What is the difference between the sy-tabix & sy-index ?
sy-tabix & sy-index
/message/4752267#4752267 [original link is broken]
sy-index & sy-tabix
Reward points.. -
Diff b/n sy-tabix and sy-indx
diff b/n sy-tabix and sy-indx ?
Hi Henry,
SY-INDEX is the value of the current iteration. It is applicable for the following programming constructs in ABAP -
DO...ENDDO.
WHILE...ENDWHILE.
SY-TABIX (TABle IndeX) is applicable to internal tables. If you scroll down in the link which Eddie has given, you will find a more detailed explanation for sy-tabix and which statements affect its value.
Regards,
Anand Mandalika. -
Urgent....!!!
Dear all,
Pls let me know diff b/w sy-tabix & sy-index?
Hoping for your Response...!!!hi ,
1. SY-INDEX is used to describe the number of iteration with in the DO..ENDDO, WHILE ...ENDWHILE....
SY-TABIX is used to define the iteration with in the internal table like between LOOP AT & ENDLOOP.
2. SY-TABIX : gives the Current line of an internal table
example
SEARCH T FOR 're'.
READ TABLE T INDEX SY-TABIX.
SY-INDEX : gives the Number of loop passes.
example
DO 5 TIMES.
WRITE: SY-INDEX.
ENDDO.
3. Sy-tabix is used to find the current line in the internal table; its a current line index, Table Index. This signifies the number of table index. Each row of a table has certain index or counter. The value of sy-tabix for the last entry would be equivalent to number of table entries.
SY-INDEX is the number of Iterations for a loop. bascially DO - ENDO .
SY-INDEX is not equal to SY-TABIX.
some more info.............
SY-TABIX:
Current line in an internal table. With the following statements SY-TABIX is set for index tables. With hashed tables, SY-TABIX is not filled or it is set to 0.
reagrds,
venkat. -
dear experts
1. what is the exact difference between sy-tabix and sy-index. explain in detail.
2.diference between sm36 and sm37.
3. on which server we exactly do UTP(unit test planning) what is the procedure.
thankx
baleeqHi,
Here is an example from which you can understand the difference between sy-tabix and sy-index.
Itab is an internal table with the following data in it.
id Name
198 XYZ
475 ABC
545 PQR.
loop at itab where id > 300.
write :/ itab-id, itab-name , sy-tabix, sy-index.
endloop.
My output will be :
475 ABC 2 1
545 PQR 3 2
Sy-tabix is the index of the record in internal table.
sy-index gives the no of times of loop passes.
So, for the first record in the output (475 ABC), 2 is the index of the record in internal table and as it is first time loop pass occured, sy-index value is 1.
Regards,
sailaja. -
hi,
can u please tell me how sy-tabix,sy-index works in a loop.what is the difference between them.
thanks in advance,
shekarHi Shekar,
<b>In simple terms.....</b>
1. Remember SY-TABIX always points to internal table index.
i.e., when you want to insert,read or delete a record into the internal table,you need this index and
LOOP AT itab.
ENDLOOP.
2.SY-INDEX contains the number of loop passes in DO and WHILE loops, including the current loop pass(Ordinary definition).
Simple example of a DO loop :
DO.
WRITE SY-INDEX.
IF SY-INDEX = 3.
EXIT.
ENDIF.
ENDDO.
The output is:
1 2 3
The loop is processed three times. Here, the processing passes through the loop three times and then leaves it after the EXIT statement.
<b>In this second example you know how exactly this SY-INDEX is working in loop include nested loops <b>(VERY IMPORTANT)</b></b>
Example of two nested loops with the TIMES addition:
DO 2 TIMES.
WRITE SY-INDEX.
SKIP.
DO 3 TIMES.
WRITE SY-INDEX.
ENDDO.
SKIP.
ENDDO.
The output is:
1
1 2 3
2
1 2 3
<b>
Reward all helpful answers</b>
Regards,
V.Raghavender. -
Regarding upload from excel to alv.
Hi
here is my code:
TABLES
TABLES: ioheader, " IOC Communication structure
ioitem, " IOC Communication structure
klah, " Class and Class type
ksml, " Characteristic Keys for Class and Type
cabn, " Characteristics
cabnt, " Characteristic Descriptions
vbap, " SAles details
sscrfields.
Includes
INCLUDE rvreuse_global_data. " ALV Types etc
DATA - INTERNAL TABLES AND FIELD LISTS
Types
TYPE-POOLS: ibco2. " Characteristic types
DATA - CONSTANTS
CONSTANTS: c_true(1) TYPE c VALUE 'X',
c_false(1) TYPE c VALUE ' ',
c_zioheader TYPE dd02l-tabname VALUE 'ZIOHEADER',
c_command TYPE slis_formname VALUE 'USER_COMMAND',
c_backhoe(7) TYPE c VALUE 'BACKHOE',
c_300(3) TYPE c VALUE '300',
c_no_data(7) TYPE c VALUE 'No Data',
c_save(1) TYPE c VALUE 'A'.
Internal Tables
Main IO Table
DATA: i_header LIKE zioheader OCCURS 0 WITH HEADER LINE.
Characteristic Values
DATA: i_config TYPE ibco2_instance_tab2.
Characteristics Keys
DATA: BEGIN OF i_imerk OCCURS 0,
imerk LIKE ksml-imerk,
END OF i_imerk.
ALV Grid Control
DATA: i_grid TYPE sd_alv.
Catalogues
DATA: wa_cat LIKE LINE OF i_grid-fieldcat.
Structures
Structure for layout variant
DATA: s_variant LIKE disvariant.
DATA : filename TYPE string.
DATA - WORKING VARIABLES
DATA - FIELD GROUPS
*field-groups:
SELECTION SCREEN
Variant control
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
PARAMETERS: p_var LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b1.
Printer Control
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
PARAMETERS: rad1 RADIOBUTTON GROUP rad USER-COMMAND radio,
rad2 RADIOBUTTON GROUP rad,
rad3 RADIOBUTTON GROUP rad.
PARAMETER p_floc(128) DEFAULT '/usr/tmp/testfile.dat'
LOWER CASE.
SELECTION-SCREEN END OF BLOCK b3.
MAIN PROGRAM *************************
INITIALIZATION.
PERFORM initialise. " Set up program defaults
move 'Report Only' to rad1.
move 'Export Sequence List' to s_but2.
move 'Import Sequence List' to S_but3.
Selection Screen Options
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
PERFORM get_variant CHANGING p_var. " ALV Layout
DATA : l_no_of_lines TYPE i,
la_matnr LIKE s_matnr.
DESCRIBE TABLE s_matnr LINES l_no_of_lines.
IF l_no_of_lines > 1.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
READ TABLE s_matnr INTO la_matnr WITH KEY sign = 'I'
option = 'EQ'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
AT SELECTION-SCREEN.
DATA : l_no_of_lines TYPE i,
la_matnr LIKE s_matnr.
DESCRIBE TABLE s_matnr LINES l_no_of_lines.
IF l_no_of_lines > 1.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
READ TABLE s_matnr INTO la_matnr WITH KEY sign = 'I'
option = 'EQ'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Enter only one product'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_floc.
data : pname type syst-repid.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = pname
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FLOC'
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = p_floc
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
PERFORM set_catalogue. " Set up basic headings from Itab
PERFORM get_char_keys. " Get the characteristic keys
PERFORM modify_catalogue_key. " Amend headings for char keys
IOC Logical Database Event
GET ioheader.
PERFORM get_subsequent_data. " Retrieve additional data
END-OF-SELECTION.
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
if rad1 = 'X' .
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
elseif rad2 = 'X' .
*if p_floc is initial .
MESSAGE e000(z1) WITH
' Enter the file location'.
*else.
PERFORM download. " Export sequence list to excel
PERFORM modify_catalogue_title. " Place correct titles for AVL
PERFORM alv_display. " Display in ALV Grid
*endif.
elseif rad3 = 'X' .
if p_floc is initial .
MESSAGE e000(z1) WITH
' Enter the file location'.
else .
PERFORM upload.
endif.
endif.
*AT SELECTION-SCREEN OUTPUT.
*TOP-OF-PAGE.
*END-OF-PAGE.
*AT USER-COMMAND.
perform PF_STATUS_SET.
SUBROUTINES *******************************
FORM get_variant *
Retrieve ALV display variant *
--> X_VAR Variant *
FORM get_variant CHANGING x_var.
PERFORM f4_alv_layout(ppio_entry) USING i_grid-program
CHANGING x_var.
ENDFORM.
FORM get_subsequent_data *
Retrieve additional data and place into I_HEADER Itab *
FORM get_subsequent_data.
Prime extended table
i_header = ioheader.
PERFORM get_serial_number. " Get Sales Order Serial No
PERFORM get_char_values. " Get Characteristic Values
PERFORM build_char_entries." Put Char Values into I_HEADER
Add to extended table
APPEND i_header.
ENDFORM.
FORM get_serial_number *
Retrieve the serial number *
FORM get_serial_number.
SELECT SINGLE zuonr submi
INTO (i_header-zuonr,i_header-submi)
FROM vbak
WHERE vbeln EQ i_header-kdauf_aufk.
ENDFORM.
FORM get_char_values *
Retrieve the characteristic values for the production order *
FORM get_char_values.
Get Ready
REFRESH i_config.
Get Object key
SELECT SINGLE cuobj
FROM vbap
INTO vbap-cuobj
WHERE vbeln EQ i_header-kdauf_aufk
AND matnr EQ i_header-plnbez.
Get characteristic config values
CALL FUNCTION 'CUCB_GET_CONFIGURATION'
EXPORTING
instance = vbap-cuobj
IMPORTING
configuration = i_config
EXCEPTIONS
invalid_input = 1
invalid_instance = 2
instance_is_a_classification = 3
OTHERS = 4.
Not found, no config values will be pulled through
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
FORM build_char_entries *
For each character value. Find the relevent "slot" in the *
table by checking the characteristic key against the catalogue*
stored key
FORM build_char_entries.
DATA: la_config LIKE LINE OF i_config, " i_config header line
li_values TYPE ibvalue0 OCCURS 0, " Charact'ic Values Itab
la_values LIKE LINE OF li_values, " li_values header line
l_atwrt LIKE la_values-atwrt, " Characteristic Value
l_atinn LIKE la_values-atinn, " Characteristic Key
l_key(20), " Working built key
l_entry(20), " FieldName to be updated
l_len LIKE sy-tabix, " Length of string
l_tabix LIKE sy-tabix. " Index position of Itab
FIELD-SYMBOLS: <f_field>. " This will be the field to update
Loop on characteristics
LOOP AT i_config INTO la_config.
Extract the characteristic values imbedded table
MOVE la_config-values TO li_values.
Loop on the characteristics values
LOOP AT li_values INTO la_values.
We now have the charecteristic key la_values-atinn
and the value in la_values-atwrt. However, there may be
Multiple values for key la_values-atinn
So if they are the same append to one long string.
Is it a new value
IF la_values-atinn EQ l_atinn.
CONCATENATE l_atwrt '|' la_values-atwrt INTO l_atwrt.
CONTINUE.
ENDIF.
New Value (and not first pass) so save built values
IF NOT l_atinn IS INITIAL.
Find the correct field to place the value in.
This is done by finding the Itab field description in the AVL display
field Catalogue called "No Data|nnnnnn" where nnnn is the
characteristic Key
Build the key
CONCATENATE c_no_data '|' l_atinn INTO l_key.
Loop till we find it. This gives us the field name
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l = l_key.
Set up the field name to be amended
CONCATENATE wa_cat-tabname '-' wa_cat-fieldname INTO l_entry.
ASSIGN (l_entry) TO <f_field>.
Update field with the Char value
MOVE l_atwrt TO <f_field>.
No need to continue this loop
EXIT.
ENDLOOP.
ENDIF.
Prime for next value
l_atinn = la_values-atinn.
l_atwrt = la_values-atwrt.
ENDLOOP.
ENDLOOP.
ENDFORM.
FORM alv_display *
Display data in ALV grid *
FORM alv_display.
Set up Variant
i_grid-variant-variant = p_var. " Variant
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = i_grid-program
I_CALLBACK_PF_STATUS_SET = i_grid-pf_status_set
i_callback_user_command = i_grid-user_command
i_structure_name = i_grid-structure
is_layout = i_grid-layout
it_fieldcat = i_grid-fieldcat
IT_EXCLUDING = i_grid-excluding
IT_SPECIAL_GROUPS = i_grid-special_groups
IT_SORT = i_grid-sort
IT_FILTER = i_grid-filter
IS_SEL_HIDE = i_grid-sel_hide
I_DEFAULT = i_grid-default
i_save = I_grid-save
is_variant = i_grid-variant
IT_EVENTS = i_grid-events
IT_EVENT_EXIT = i_grid-event_exit
IS_PRINT = i_grid-print
IS_REPREP_ID =
I_SCREEN_START_COLUMN = i_grid-start_column
I_SCREEN_START_LINE = i_grid-start_line
I_SCREEN_END_COLUMN = i_grid-end_column
I_SCREEN_END_LINE = i_grid-end_line
IMPORTING
E_EXIT_CAUSED_BY_CALLER = i_grid-exit
ES_EXIT_CAUSED_BY_USER = i_grid-user_exit
TABLES
t_outtab = i_header
EXCEPTIONS
program_error = 1
OTHERS = 2.
ALV Failed.
IF sy-subrc <> 0.
WRITE: / 'Failed with',sy-subrc.
ENDIF.
ENDFORM.
FORM initialise *
Set up basic report details *
FORM initialise.
ALV controls
i_grid-program = sy-repid. " Program Name
i_grid-user_command = c_command. " ALV user FORM
i_grid-save = c_save. " Save Options
ALV Variant Details for saved report layouts
i_grid-variant-report = i_grid-program.
i_grid-variant-username = sy-uname.
ENDFORM.
FORM user_command *
Routine called by ALV *
--> X_UCOMM Function selected *
--> X_SELFIELD Selection field Itab *
FORM user_command USING x_ucomm LIKE sy-ucomm
x_selfield TYPE slis_selfield.
DATA: l_answer(1). " Answer returned from popup box
Only allow drill down on Order number
CHECK x_selfield-fieldname = 'AUFNR'.
Get option for display or modify
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
textline1 = 'Please Choose'
text_option1 = 'Display'
text_option2 = 'Modify'
titel = 'Production Order'
IMPORTING
answer = l_answer.
Did they cancel
CHECK l_answer NE 'A'.
Set up parameters.
SET PARAMETER ID 'ANR' FIELD x_selfield-value.
Display
IF l_answer = '1'.
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
Modify
ELSEIF l_answer = '2'.
CALL TRANSACTION 'CO02' AND SKIP FIRST SCREEN.
ENDIF.
*IF rad2 = 'X'.
If sy-ucomm ='%PC'.
IF sy-subrc <> 0.
WRITE: / 'Failed with',sy-subrc.
else.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'File Transfer Status'
TXT1 = 'File transfered to location:'
TXT2 = filename
TXT3 = ' '
TXT4 = ' '
ENDIF.
endif.
ENDFORM.
FORM set_catalogue *
Retrieve the title and field information from the *
Data Dictionary. This will then be amended to the correct *
Characteristic titles during the end-of-selection event *
FORM set_catalogue.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_grid-program
i_internal_tabname = 'I_HEADER'
i_structure_name = c_zioheader
i_client_never_display = 'X'
CHANGING
ct_fieldcat = i_grid-fieldcat.
ENDFORM.
FORM get_char_keys *
Retrieve the list of characteristic keys *
template of BACKHOE class 300 *
FORM get_char_keys.
DATA : la_inob TYPE inob.
SELECT SINGLE * FROM inob INTO la_inob
WHERE objek = s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH
' Could not get INOB table for ' s_matnr-low.
ENDIF.
Get Major Object key
SELECT SINGLE clint
FROM klah
INTO klah-clint
WHERE klart = la_inob-klart
AND class = s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e001(z296) WITH c_backhoe c_300.
ENDIF.
Use Major key to retrieve Characteristics keys
This is the template for the headings
SELECT imerk
FROM ksml
INTO TABLE i_imerk
WHERE clint EQ klah-clint " Objct Key
AND lkenz EQ space " Delete Indicator
AND datuv LE sy-datum. " Validity to
IF sy-subrc NE 0.
MESSAGE e002(z296) WITH klah-clint.
ENDIF.
ENDFORM.
FORM modify_catalogue_key *
Change the default "No Data" titles with the characteristic *
key values in the form "No Data|nnnnnnn" where nnnnnn is *
the characteristic key. This is used as a method of allocating*
characteristic values to the I_HEADER Itab positions *
CHAR_001 to CHAR_100 *
FORM modify_catalogue_key.
DATA: l_index LIKE sy-tabix, " Table Index for Read
l_tabix LIKE sy-tabix, " Table Index Position
l_seltext_l LIKE dd03p-scrtext_l. " Heading Text
Get into Key Sequence
SORT i_imerk.
Loop on catalogue for dummy titles
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l(7) = c_no_data.
l_tabix = sy-tabix.
Get the next characteristic
l_index = l_index + 1.
READ TABLE i_imerk INDEX l_index.
No Characteristic, No display
IF sy-subrc NE 0.
wa_cat-no_out = c_true.
wa_cat-tech = c_true.
MODIFY i_grid-fieldcat FROM wa_cat INDEX l_tabix.
CONTINUE.
ENDIF.
Place the char key against the "No Data" title
so that later we know what values to place against the keys
the title will become "No Data:nnnnnnnnnn" (nnn = Key)
CONCATENATE c_no_data '|' i_imerk-imerk INTO wa_cat-seltext_l.
MODIFY i_grid-fieldcat FROM wa_cat INDEX l_tabix.
ENDLOOP.
ENDFORM.
FORM modify_catalogue_title *
At this stage the catalogue titles for the characteristics *
are in the form "No Data|nnnnn" Where nnnn is the *
characteristic key. Using the Key, replace this text with *
the real characteristic title
FORM modify_catalogue_title.
DATA: l_key(20), " Characteristic Key in Alpha form
l_len LIKE sy-tabix. " Length of string
Loop on the characteristic keys
LOOP AT i_imerk.
Get the real title
SELECT SINGLE atbez
FROM cabnt
INTO cabnt-atbez
WHERE atinn EQ i_imerk-imerk.
Not found, leave alone
CHECK sy-subrc EQ 0.
Place key into char form for comparison in loop
l_key = i_imerk-imerk.
Now loop on the catalogue to get the key
LOOP AT i_grid-fieldcat INTO wa_cat WHERE seltext_l+8 = l_key.
Place the title into the catalogue
wa_cat-seltext_l = cabnt-atbez.
wa_cat-seltext_m = cabnt-atbez.
wa_cat-seltext_s = cabnt-atbez.
wa_cat-reptext_ddic = cabnt-atbez.
And update
MODIFY i_grid-fieldcat FROM wa_cat.
ENDLOOP.
ENDLOOP.
IF rad2 = 'X'.
LOOP AT i_grid-fieldcat INTO wa_cat.
*IF wa_cat-fieldname = 'AUFNR'.
*wa_cat-col_pos = '10'.
*endif.
case wa_cat-fieldname.
when 'AUFNR'.
wa_cat-fix_column = 'X'.
when 'CY_SEQNR'.
wa_cat-fix_column = 'X'.
when 'ZOUNR'.
wa_cat-fix_column = 'X'.
when 'GLTRP'.
wa_cat-fix_column = 'X'.
when 'SUBMI'.
wa_cat-fix_column = 'X'.
endcase.
modify i_grid-fieldcat FROM wa_cat.
endloop.
endif.
ENDFORM.
*SELECT z099seqno z099heading
INTO table i_header
FROM z099 join z100 ON
z099seqno = z100seqno WHERE
z100~product = s_matnr.
*& Form download
Download file to excel
*FORM download.
*filename = p_floc .
*CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = filename
FILETYPE = 'ASC'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = ','
HEADER = 'l_seltext_l'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_header
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
WRITE: / 'Failed with',sy-subrc.
else.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'File Transfer Status'
TXT1 = 'File transfered to location:'
TXT2 = filename
TXT3 = ' '
TXT4 = ' '
ENDIF.
*ENDFORM. " download
*& Form upload
text
--> p1 text
<-- p2 text
FORM upload.
*DATA : i_upload TYPE STANDARD TABLE OF alsmex_tabline.
**data : i_upload like zioheader occurs 0 with header line.
data file like RLGRAP-FILENAME.
file = p_floc .
DATA: BEGIN OF i_upload OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF i_upload.
DATA: BEGIN OF i_upload1 OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF i_upload1.
DATA: BEGIN OF t_col OCCURS 0,
col LIKE alsmex_tabline-col,
size TYPE i.
DATA: END OF t_col.
DATA: zwlen TYPE i,
zwlines TYPE i.
DATA: BEGIN OF fieldnames OCCURS 3,
title(60),
table(6),
field(10),
kz(1),
END OF fieldnames.
DATA: tind(4) TYPE n.
FIELD-SYMBOLS: <fs1>.
DATA: zwfeld(19).
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = file
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '200'
I_END_ROW = '6500'
TABLES
INTERN = i_upload.
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 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 i_upload.
i_upload1 = i_upload.
CLEAR i_upload1-row.
APPEND i_upload1.
ENDLOOP.
SORT i_upload1 BY col.
LOOP AT i_upload1.
AT NEW col.
t_col-col = i_upload1-col.
APPEND t_col.
ENDAT.
zwlen = strlen( i_upload1-value ).
READ TABLE t_col WITH KEY col = i_upload1-col.
IF sy-subrc EQ 0.
IF zwlen > t_col-size.
t_col-size = zwlen.
Internal Table, Current Row Index
MODIFY t_col INDEX sy-tabix.
ENDIF.
ENDIF.
ENDLOOP.
DESCRIBE TABLE t_col LINES zwlines.
SORT i_upload BY row col.
IF kzheader = 'X'.
LOOP AT i_upload.
fieldnames-title = i_upload-value.
APPEND fieldnames.
AT END OF row.
EXIT.
ENDAT.
ENDLOOP.
ELSE.
DO zwlines TIMES.
WRITE sy-index TO fieldnames-title.
APPEND fieldnames.
ENDDO.
ENDIF.
SORT i_upload BY row col.
LOOP AT i_upload.
IF kzheader = 'X'
i_upload-row = 1.
CONTINUE.
ENDIF.
tind = i_upload-col.
CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
ASSIGN (zwfeld) TO <fs1>.
<fs1> = i_upload-value.
AT END OF row.
APPEND i_upload.
CLEAR i_upload.
ENDAT.
ENDLOOP.
if sy-subrc = 0.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = i_grid-program
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = i_grid-fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = i_save
IS_VARIANT = i_grid-variant
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_upload.
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
when i execute the program i am getting a short dump
GETWA_NOT_ASSIGNED
what might be the problem.
this is a very urgent question.
pls suggest me the clear way to over come this problem.HI
use this code for uploading the excel file to internal table....
data: begin of itab_string occurs 0,
record type char255,
end of itab_string.
data: L_FILETABLE TYPE FILETABLE,
L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.
data: p_file1 type string.
selection screen .
PARAMETERS: P_FILE TYPE LOCALFILE.
initialization.
at selection-screen on value-request for P_FILE.
IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = 'C:\Documents and Settings\196093\Desktop\STATUS.csv'
FILE_FILTER =
INITIAL_DIRECTORY = 'C:\Documents and Settings\196093\Desktop\'
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = L_FILETABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
IF SY-SUBRC <> 0.
ELSE.
LOOP AT l_filetable INTO L_FILETAB_H.
P_FILE = L_FILETAB_H-FILENAME.
move p_file to p_file1.
EXIT.
ENDLOOP.
ENDIF.
passing the selected file name to gui_upload for loading the data
into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab_string
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE I000(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.
ENDIF.
reward points to all helpful answers
kiran.M -
MVC - Performance of data binding
Hi Gurus out there
I have a concern regarding performance of (dynamic) data binding if I have a lot of <i>textEdit</i> fields containing huge amount of data on a view page.
<u>Scenario</u>:
The view page contains buttons <b>[Add textEdit field]</b> and<b> [Save all entries]</b>. If you click the button <b>[Add textEdit field]</b> then a (new) <i>textEdit</i> will be generated and the model remembers the total number of <i>textEdit</i> fields that have been generated.
DATA: textedit_count TYPE i,
o_textedit TYPE REF TO cl_htmlb_textedit,
tabix(6) TYPE c,
binding_code TYPE string,
binding_str TYPE string.
textedit_count = o_model->get_section_count( ).
DO textedit_count TIMES.
* Create a unique ID for a textEdit field:
tabix = sy-index.
CONDESE tabix NO-GAPS.
* String for the data binding of internal table model->data_stream_tab:
CONCATENATE '//model/data_stream_tab['
tabix
'].data_string'
INTO binding_str.
* Dynamic data binding:
CREATE OBJECT o_textedit.
CONCATENATE 'myTextEditID' tabix
INTO o_textedit->id.
o_textedit->width = 650.
o_textedit->height = 225.
o_textedit->_text = binding_str.
binding_code = o_textedit->IF_BSP_BEE~RENDER_TO_STRING( page_context ).
<htmlb:label for = "<%= o_textedit->id %>"
text = "<%= o_textedit->id %>"
design = "EMPHASIZED" />
<%-- Binding of the attribute (internal table) '//model/data_stream_tab<i>.data_stream' --%>
<%= binding_code %>
ENDDO.
Obviously the <u>whole</u> contents of the <i>textEdit</i> fields in the coding above are <u>always</u> "moved" from the web browser to the server and vice versa when the button <b>[Add textEdit field]</b> is hit every time even though the content of some <i>textEdit</i> fields haven't changed.
Does anyone have a good solution/optimization for this problem? Any suggestion, comment and/or answer will be very appreciated.
Thanks
HWPlace this code above any textedit elements you have in your page:
<script type="text/javascript">
var myFields = new Array();
</script>
Then place this code after every textedit elements, this code will get run when the page is loaded in the browser, right after your element. You are saving the ID and the default value of your element to an array. For every further element, increase the array counter by 1!
<script type="text/javascript">
myFields[0] = new Object();
myFields[0]["id"] = 'myTextEdit1';
myFields[0]["default_value"] = document.getElementById(myFields[0]["id"]).value;
</script>
Finally, include this function in your page (does not have to be at the bottom, I just put it here chronologically):
<script type="text/javascript">
function compareFields() {
for (var i = 0; i < myFields.length; ++i) {
if(myFields<i>["default_value"] == document.getElementById(myFields<i>["id"]).value) {
// nothing has changed, set to ignore-value (any highly unlikely value, like ")?.("
document.getElementById(myFields<i>["id"]).value = ')?.(';
// check against this value in your setter method
// if this is set, then do not user submitted value to update your model attribute value
// maybe do some output for debug purposes
// alert(document.getElementById(myFields<i>["id"]).value);
}</script>
Now add this attribute to your submit button:
onClientClick = "javascript:compareFields();"
This should do, test it out and let me know.
Max -
Regarding column editing in alv grid
hi experts,
i m using alv grid display for my report layout what i want that after the output dispaly when the user will select my customized button "change the amount column" then after pressing this my amount column will become editable and user can put there new aount for this i have used this codes but it is not working plz help me to sort out this,
for u here is my code.
FORM DISPLAY_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
is_layout = i_layout
it_fieldcat = i_fieldtab
i_grid_title = 'Production Incentive Details'
I_CALLBACK_PF_STATUS_SET = 'SET_PFSTATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
it_events = global_events
TABLES
t_outtab = itab_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " DISPLAY_LIST
*& Form SET_PFSTATUS
text
-->RT_EXTAB text
FORM SET_PFSTATUS USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'ZPINCENTIVE' .
EXCLUDING rt_extab..
ENDFORM. " CREATE_PFSTATUS
*& Form user_command
text
-->R_UCOMM text
-->RS_SELFIELD text
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
*BREAK-POINT.
when '&CHANGED'. "for change the amount button.
read table i_fieldtab into s_fieldtab with key FIELDNAME = 'AMOUNT'.
if sy-subrc = 0.
move:sy-tabix to index,
'X' to s_fieldtab-edit.
modify:i_fieldtab index index from s_fieldtab.
clear:s_fieldtab.
endif.solved by own
-
Anyone have any idea why I can't get my popupmenu to work? I have two sets of data, one we'll call code groups and the other group items. I simply want the group items to be a submenu of their group. I can get exactly one group item to slide out, and it looks strange in a large font.
Anyone see something I don't?
method ZFILL_OTEIL_POPUP .
data: wa_popup like line of oteilgroup,
lv_group type zqpgt_tab,
lv_item type zqpct_tab,
lv_text type string,
separator(3) value ' - '.
field-symbols: <group> type zqpgt,
<item> type zqpct.
lv_group = me->zget_group_codes( p_katalogart = 'B' ).
lv_item = me->zget_item_codes( p_katalogart = 'B' ).
data: id type string,
index type string.
loop at lv_group assigning <group>.
clear wa_popup.
clear id.
refresh oteilitem.
move sy-tabix to index.
concatenate 'oteilSubPopup' index into id.
concatenate <group>-codegruppe <group>-kurztext into lv_text
separated by separator.
wa_popup-menuitemid = 'oteilPopup'.
wa_popup-submenuid = id.
wa_popup-text = lv_text.
wa_popup-cancheck = 'X'.
wa_popup-enabled = 'X'.
append wa_popup to oteilgroup.
loop at lv_item assigning <item>
where codegruppe = <group>-codegruppe.
clear wa_popup.
concatenate <item>-code <item>-kurztext into lv_text
separated by separator.
wa_popup-menuitemid = id.
wa_popup-text = lv_text.
wa_popup-cancheck = 'X'.
wa_popup-enabled = 'X'.
append wa_popup to oteilitem.
endloop.
append oteilitem to oteilitems. "deeply structured itab
endloop.
endmethod.
LAYOUT
<td><htmlb:label for="object" text="Object Code"/></td>
<td><htmlb:inputField id="damage" value="//model/notif_fields.fecod" disabled="true"/>
<phtmlb:popupTrigger id="oteilTrigger"
popupMenuId="oteilPopup"
isInteractive="true" >
<htmlb:image src="s_b_hint.gif" />
</phtmlb:popupTrigger>
<phtmlb:popupMenu id="oteilPopup"
firstVisibleItemIndex="1"
maxVisibleItems="25"
items="<%=oteilgroup%>">
</phtmlb:popupMenu>
<% data: wa_item type PHTMLB_POPUPMENUITEMS,
id type string,
index type string. %>
<% loop at oteilitems into wa_item.
move sy-tabix to index.
concatenate 'oteilSubPopup' index into id. %>
<phtmlb:popupMenu id="<%= id %>"
onSelect="myOteil"
firstVisibleItemIndex="1"
maxVisibleItems="25"
items="<%= wa_item %>">
</phtmlb:popupMenu>
<% refresh wa_item. %>
<% endloop. %>Hi Thomas,
Thanks for the reply.
As you have said there are no background or MouseOver color for popupMenu. I am using a workaround for this by putting the popMenuItems in an html table and then changing the above said attributes for the individual cells. This works fine in normal menu but no effect when used with popupMenu. If you want I can send you the code but that will be possible tomorrow.
Regards
PRAFUL
Maybe you are looking for
-
I am recently married to a wonderful woman and just built a windows PC for the first time. The idea was that we would (sorta) both be able to get a new computer out of it as we would each have a different account under windows. One of the first tasks
-
How do you get money credited back when your child mistakenly buys an app while playing a free kids game? We need to refund the charges and apps that were mistakenly purchased by a child while playing a free kids game on Ipad.
-
Hi experts: I need a Project Accounting Report that shows Original and Current budget together with PTD,ITD,MTD and YTD labor amount, labor cost, non-labor cost, and revenue on the same line for all the task_id for a project. I know these are coming
-
Corrupt catalog cannot be repaired
Lightroom Catalog corrupt. Can't be repaired. I was uploading a photo shoot to Lightroom 2.7. A few minutes in, I got the following message: Lightroom encountered an error and needs to quit. There was a problem reading one of the Lightroom catalogs
-
I have two of the same exact G4 800mhz laptops, one with a bad logic board and one with a cracked display, put them together and I have a brand new laptop, although I cant seem to figure out why I cant get the logic board out. How can I do this? Both