Dynamically inserting new line in Internal table
Hi,
Can anyone help me how to insert a new line dynamically to the internal table.
Assume there are 5 records that has been added to ITAB.
In that if a particular field in that ITAB crosses the limit 10 then i have to split that line into two lines with the same data except that Par.field as 5 and the other record has 5.
In the third record that particular field has value 10.
Loop at ITAB.
Once i found that field has 10 then how to insert a new line dynamically over here to add another record.
endloop.
Hi..
Hi..
try this..
loop at itab.
if ( i found that field <f1> has 10 ).
w_line2 = itab-f1+5(5).
w_line3 = itab-f1.
***********First line********
itab-f1 = itab-f1+0(5).
modify itab index sy-tabix from itab transporting f1.
***********second line******** Hi..
try this..
loop at itab.
if ( i found that field <f1> has 10 ).
w_line2 = itab-f1+5(5).
w_line3 = itab-f1.
***********First line********
itab-f1 = itab-f1+0(5).
modify itab index sy-tabix from itab transporting f1.
***********second line********
itab-f1 = w_line2.
insert itab INDEX SY-TABIX.
**********third line**************
itab-f1 = w_line3.
insert itab INDEX SY-TABIX.
endloop.
itab-f1 = w_line2.
insert itab INDEX SY-TABIX.
**********third line**************
itab-f1 = w_line3.
insert itab INDEX SY-TABIX.
endloop.
Similar Messages
-
Inserting blank line in internal table
Hi
I am inserting a report from a internal table for eg the content of my internal table is
data : abc
event initialization.
perform read_data.
Now I want 1 blank line after every line in the internal table for eg
data:abc
event initialization
perform read_data.
How to insert a blank line in an internal table?
Edited by: priya singh on Feb 4, 2009 9:37 AMhi,
DATA: BEGIN OF i_pernr OCCURS 1 ,
pernr TYPE pa0002-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
END OF i_pernr.
TYPES : BEGIN OF string1 ,
a TYPE char100,
END OF string1.
DATA : wa_string TYPE string1,
it_stirng TYPE TABLE OF string1.
START-OF-SELECTION.
SELECT pernr vorna nachn FROM pa0002 INTO TABLE i_pernr UP TO 20 ROWS.
LOOP AT i_pernr.
CONCATENATE i_pernr-pernr i_pernr-vorna i_pernr-nachn INTO wa_string-a SEPARATED BY '|'.
APPEND wa_string TO it_stirng.
APPEND INITIAL LINE TO it_stirng.
ENDLOOP.
BREAK-POINT.
Thanks -
ASSIGN to add new lines to internal tables
Hello,
within our code, I have found several occurrences of the obsolete ASSIGN LOCAL COPY which I would like to replace with up-to-date coding. Particularly, we have the following code segment:
DATA: ct_table TYPE INDEX TABLE.
FIELD-SYMBOLS: <ls_new_row> TYPE ANY,
<lv_field> TYPE ANY.
ASSIGN LOCAL COPY OF INITIAL LINE OF ct_table TO <ls_new_row>.
ASSIGN COMPONENT '1' OF STRUCTURE <ls_new_row> TO <lv_field>.
<lv_field> = ...
ASSIGN COMPONENT '2' OF STRUCTURE <ls_new_row> TO <lv_field>.
<lv_field> = ...
INSERT <ls_new_row> INTO TABLE ct_table.
What is the most efficient non-obsolete code equivalent for this?
--FlorianYou might also use the command INSERT INITIAL LINE INTO TABLE itab ASSIGNING <fs>.
You will encounter problems with this solution if the internal table has key components as the system will not allow you to change these in this setup after the insertion. -
Error at Insert new Line in the Table (ITERATOR)
public String novaLinhaTabela() {
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
//access the name of the iterator the table is bound to. Its "allDepartmentsIterator"
//in this sample
DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("crudArquivosLinhasColunas_parametersIterator");
//access the underlying RowSetIterator //crudArquivoLinhasColunasControlIterator crudArquivosLinhasColunas_parametersIterator
RowSetIterator rsi = dciter.getRowSetIterator();
System.out.println("RSI " + rsi);
//get handle to the last row
Row lastRow = rsi.last();
//obtain the index of the last row
int lastRowIndex = rsi.getRangeIndexOf(lastRow);
//create a new row
Row newRow = rsi.createRow();
//initialize the row
newRow.setNewRowState(Row.STATUS_INITIALIZED);
//add row to last index + 1 so it becomes last in the range set
rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
//make row the current row so it is displayed correctly
rsi.setCurrentRow(newRow);
ADFUtils.addPartialTarget(this.tabelaColunaLinha);
return null;
This line have the return of NULL POINTER EXCEPTION, I am not able to solve.
RowSetIterator rsi = dciter.getRowSetIterator();
Someone could help me?Gijith,
You know how to add a row in the table by clicking on the? I can not, I am new in ADF, I struggle to ride it!
Could you help me friend? -
New Line after every 900 lines in internal table
HI,
I have an internal table and that is sorted by company code. i.e it is grouped according to company code.
Now i want to check in particular groups of company code if the lines of internal table is > 900 or not.
And if it > 900 i have to insert new line.
How to do that?Hi
Please check the code..I think it will solve ur problem
TYPES : BEGIN OF x_data,
name TYPE char10,
END OF x_data.
data: i_data TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
wa_data TYPE x_data,
counter TYPE n LENGTH 2 .
DO 5 TIMES.
CLEAR : wa_data.
counter = counter + 1.
CONCATENATE 'subha' counter INTO wa_data-name.
APPEND wa_data to i_data.
ENDDO.
CLEAR : counter,
wa_data .
DESCRIBE TABLE i_data LINES counter.
IF counter > 4.
counter = 5.
wa_data-name = 'TEST'.
INSERT wa_data INTO i_data INDEX counter.
ENDIF.
CLEAR: wa_data.
LOOP at i_data INTO wa_data .
WRITE : / wa_data-name.
ENDLOOP.
Use 900 instead 4 and 901 instead of 5. -
@Inserting Records in an Internal Table
Hi,
How can I Insert records in an internal table..such that i can insert the records somewhere in the middle based on the entry in a field?INSERT wa INTO TABLE itab INDEX idx .
Effect
This variant can only be used for standard tables and sorted tables. Each line line_spec to be inserted into the line before the table index idx and the table index of the following lines is increased by one. A data object of the type i is expected for idx.
If idx contains a value equal to the number of the existing table lines plus one, the new line is appended as the last line in the internal table. If idx contains a greater value, no line is inserted and sy-subrc is set to 4.
An exception that cannot be handled is raised when:
idx contains a value less than or equal to 0
A line to be inserted would cause a duplicate entry in tables with a unique table key
A line to be inserted would disrupt the sort order of sorted tables
Within a LOOP loop, you can omit the addition INDEX. Each line to be inserted is inserted before the current table line of the LOOP loop. However, if the current line is deleted in the same loop pass, the response is undefined. -
Insert new line item in va01&va02 - urgent
Hi frndz,
At the time of creation standard sales order using va01.
When user enters the sold to party in header and then
material & quantity in line item reocrds. After user enters the details in first line. I have some checks to be executed and on the basis of that customer will get the free material that should come on second line item.
I am getting the details which i will be inserting on new line item but the problem is that in which exit i should write the code for the same.
So frndz could you please let me know, in which userexit I should insert this new line item. There can be more than one free material.
If anyone has done this already, please let me know.
I know one exit i.e.MV45AFZB but in that there are many forms. so exactly which form i should where i will write the code to insert new line item???
Points will be awarded surely.
Regards,
PrashantHI Stephen,
I have the same prolem. I modified the 5 global tables, but I don't see the new line in the screen.
Can you help me with some details?
Thx!
Mihaela -
Large line to internal tables from tab delimited file
Dear All
I am trying to upload the large file of tab delimited data into a SAP internal table. I am basically stuck with the fact that there are multiple lines and multiple columns in tab delimited file. There are around 300 columns which are tab delimited and separated
For e.g (* indicates tab)
1material*****************1**9888**********5**********34*********3*********346************************-->upto 5000 columns
1material*****************1**99338************4***********************************6************7************-->upto 5000 columns
1material*****************1**22888********************5*********7*********************6*****7**************-->upto 5000 columns
1material*****************1**44844************************5***5*********************************************-->upto 5000 columns
1material***********34****1**54*******33********33*****33**************************************************-->upto 5000 columns
1material*****************1**99888*****************************************************************************-->upto 5000 columns
below upto 500 rows or more
I want to read this file into a columner internal table.
I am trying several ways . I have file on APP server. However Line breaks after 1024 characters or comes on another line.
Currently I am not able to load it in single line of internal table. The structure of file is dynamic .. not static
AmolHi Amolsonaikar,
you may try like this:
TYPES:
begin of line,
t_field type table of string,
end of line,
t_line type table of line.
DATA:
lt_line type t_line,
lv_line type string,
lt_field type table of string.
open dataset 'XYZ' for input in text mode encoding default.
while sy-subrc = 0.
read dataset into lv_line.
split lv_line at '|' into lt_field.
append lt_field to lt_line.
endwhile.
Regards,
Clemens -
Inserting new records into database table at runtime
Hi all ,
How to insert new records into database table at runtime on click update?
Thanks.Hi Sasikala,
Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
1) Obtain the reference of your context node.
2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
3) Use your normal ABAP logic to update the database table with the data from your internal table
In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
data: node_sflight type ref to if_wd_context_node,
elem_sflight type ref to if_wd_context_element,
lt_elements type WDR_CONTEXT_ELEMENT_SET,
stru_sflight type if_main=>element_sflight_node,
it_flights type if_main=>elements_sflight_node.
" navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE' ).
lt_elements = node_sflight->get_elements( ).
" Get all the rows from the table for saving on to the database
loop at lt_elements into elem_sflight.
elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
append stru_sflight to it_flights.
endloop.
" Finally save the entries on to the database
modify ZSFLIGHT99 from table it_flights.
if sy-subrc eq 0.
endif.
However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
Regards,
Uday -
How to insert new line in the copied schema with transaction code PE01?
Dear Experts,
I have copied HKT0 to ZKT0 , i want to insert new line between line 150 and line 160 in ZKT0, I don't know how to insert new line 160, who can tell me ?
Looking forward to your reply.
Best Regards,
MerryHi,
1. Open your schema,
2. In first colume "Line" select line where you want to add new line,
3. Replace first value in the column field (that indicates number of line) with character I (means insert),
4. Press enter
The line will be added. The same way you can add lines to PCR.
To delete use character D.
Cheers -
How to insert data from different internal table into a data base table
hi all,
I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
in short i want to do something like the foll:
INSERT INTO ZMIS_CODES-CODE VALUE '1'.
*INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)REPORT ZINSERT.
tables kna1.
data: itab LIKE KNA1.
data lv_kUNAG LIKE KNA1-KUNNR.
lv_kuNAG = '0000010223'.
ITAB-kuNNR = lv_kuNAG.
ITAB-name1 = 'XYZ'.
INSERT INTO KNA1 VALUES ITAB.
IF SY-SUBRC = 0.
WRITE:/ 'SUCCESS'.
ELSE.
WRITE:/ 'FAILED'.
ENDIF.
Here lv_kunag is ref to kna1 kunnr passed in different name
In internal table .
Try and let me know if this logic dint work. -
How to insert new line break in XSLT mapping
Hi experts,
I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
<xsl:text>*#xA;</xsl:text>
note: in real coding replace * with &
Can anyone suggest me how to insert new line in XSLT mapping.
My XSLT mapping as look like:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="break"><br/></xsl:variable>
<xsl:variable name="space"> </xsl:variable>
<xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
<xsl:template match="/">
<ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
<Subject>Please Check Attached Direct Debit File</Subject>
<From>S@za</From>
<To>P@za</To>
<Content_Type>text/plain</Content_Type>
<Content>
<xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
<xsl:value-of select="Space1"/>
<xsl:value-of select="Cust_AccNo"/>
<xsl:value-of select="Reserve_1"/>
<xsl:value-of select="Cust_Name"/>
<xsl:value-of select="Cust_Name1"/>
<xsl:value-of select="Cust_Bank_AccNo"/>
<xsl:value-of select="Space2"/>
<xsl:value-of select="Cust_Bank_BranchNo"/>
<xsl:value-of select="Reserve_2"/>
<xsl:value-of select="Space3"/>
<xsl:value-of select="Cust_AccNo_1"/>
<xsl:value-of select="Space4"/>
<xsl:value-of select="Reserve_3"/>
<xsl:value-of select="Deduction_Amnt"/>
<xsl:value-of select="Space5"/>
<xsl:value-of select="Reserve_4"/>
<xsl:value-of select="Space6"/>
<xsl:value-of select="Action_Date"/>
<xsl:value-of select="Space7"/>
<xsl:value-of select="Reserve_5"/>
<xsl:text>*#xA;</xsl:text>
note: in real coding replace * with &
</xsl:for-each>
</Content>
</ns1:Mail>
</xsl:template>
</xsl:stylesheet>
Kind regards,
PraveenHi,
I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
Chris
-> &
Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM -
Inserting new line to a text file at position #
Hi,.
Is it possible to do this in java?
1. Open a new text File (woutFile)
2. woutFile.write(" line #1\r\n"); // write new line
3. woutFile.write(" line #2\r\n"); // write new line
4.woutFile.write(" line #3\r\n"); // write new line
5. Go to line #2 position on a text file
6. Insert NEW LINE between line #2 and Line #3
7. move to the end-of-file
8.Close the file
Please helpIs it possible to do this? please look at question
inside comments.Your question has already been answered. Beyond that,
if you have some code and you want to know if it will
work, then run it and see.The answer was no. It's one of the fundamental properties of files that you cannot insert content in the middle, just at the end. To insert content you first have to make room for it. In this respect a file works like an array and not like a linked list. -
Data pump + inserting new values in a table
Hello Everybody!!
My question is : is it possible to insert new row into a table which is included in running DataPump process (export data) ?
Best regards
Marcin MigdalHave a look here, never done it myself but seems kind of cool :)
http://www.pythian.com/blogs/766/oracle-data-pump-11g-little-known-new-feature -
How to insert new line character?
Hi all,
I have two lines to print.
out.println("Available number of columns="+cols);
out.println("Number of columns must be present=10");My problem is:
i want both the lines to be printed one below the other. But, it is displayed in one single line.....
Can anyone please tell me how to insert new line character?
I tried with \n, '\n' and \r\n but, in vain......
Thanks for your time.
Regards,
AshviniYou should never use "\n" directly.
The line separator character is different on different operating systems.
And putting quotes around it in your string will make absolutely no difference in the JSP.
To find out what the line separator is you should use System.getProperty("line.separator");
The JSPWriter and PrintWriter classes will automatically use this property with a println statement, so a println will always finish with a line separator.
The issue here was that HTML by default ignores all whitespace.
The solutions provided
- use a <br> tag instead of a carriage return
- use <pre> tags, which tells the browser not to ignore whitespace. That can be troublesome in JSP which generates a lot of extraneous carriage returns into the code.
Cheers,
evnafets
Maybe you are looking for
-
Iphone 5s cannot call out any calls, but still can receive incoming calls and sms
Hi anyone experiencing this problem? After buying iphone 5s less than 2 months which I never did in the past, I could no longer make any phone calls out, yet i still can receive incoming calls and data. Could someone kindly assist in this?
-
How do I change/delete an iTunes Store account on the phone without restore
You know when you buy an App from the App Store it asks for your password because it's tied to the email of the account with your credit card info etc etc. Is this possible to take off/change without restoring the phone?
-
Dose any one else have problems with the iPhone 5s finger print scanner?? I've tried rescanning, different fingers, scanning different ways. But 95% of the time it just won't work. It is soooo frustring!! I would have saved a bunch of $ and bought a
-
I can not get my pictures to show in header
I am trying to use SSI in my header and it will not show the image if the page is to deep in my files: Does not work: http://www.campingcoaches.com/states/oregon/oregon.php The code is <?php include("../../includes/header2.php"); ?> but is
-
Problem with the "Total By" icon
Hi. Working with Answer I've a problem with the "Total By" icon when the fact displayed is semi-additive. I try to explain better: 1) my fact table has the following dimensions Time (year granularity) City Type of contracts 2) the fact table contains