FOR loop in ABAP Code ?
Hi,
I am working on a ABAP requirement, where I need to use a dynamic variable attached to a compilable code.
For ex:
In Jave we use
for( i=0; i >n; i++){
int i=0;
stmti+stmti = result;
Here i is an dynamic variable and it will be keep on changing ATTACHED TO stmti as stmt1.stmt2....etc. whenever there is a
change in i.
In ABAP, I have below code to attach:- Here I need to change from 1 to 100 like below. currently I see it as re-work, if i put the code each time changing manually. so I want make it in a loop and so dynamic and hence less code. How to achieve this. Please
help. Any ABAP string functions to be used?
if i=1
DATA ls_nd_tmp1 TYPE wd_this->Element_nd_tmp1.
DATA it_nd1 TYPE TABLE OF wd_this->Element_nd_tmp1.
DATA wa_nd1 TYPE wd_this->Element_nd_tmp1.
if i=2
DATA ls_nd_tmp2 TYPE wd_this->Element_nd_tmp2.
DATA it_nd2 TYPE TABLE OF wd_this->Element_nd_tmp2.
DATA wa_nd2 TYPE wd_this->Element_nd_tmp2.
Thanks
Praveen
Edited by: Praveen kumar Kadi on Sep 23, 2010 9:59 AM
>
Praveen kumar Kadi wrote:
>
> if i=1
> DATA ls_nd_tmp1 TYPE wd_this->Element_nd_tmp1.
> DATA it_nd1 TYPE TABLE OF wd_this->Element_nd_tmp1.
> DATA wa_nd1 TYPE wd_this->Element_nd_tmp1.
>
> if i=2
> DATA ls_nd_tmp2 TYPE wd_this->Element_nd_tmp2.
> DATA it_nd2 TYPE TABLE OF wd_this->Element_nd_tmp2.
> DATA wa_nd2 TYPE wd_this->Element_nd_tmp2.
>
What are you going to do with this data once you've defined it? I'd define an internal table with three fields -
TYPES: BEGIN OF my_elements_ty,
r_element1 TYPE REF TO data,
r_element2 TYPE REF TO data,
r_element3 TYPE REF TO data,
END OF my_elements_ty.
DATA: lt_elements TYPE STANDARD TABLE OF my_elements_ty,
ls_element TYPE my_elements_ty.
Then, for each iteration, build the name of the element type in strings and use something like:
CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string1).
CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string2).
CREATE DATA ls_element-r_element1 TYPE (the_type_in_the_string3).
INSERT ls_element INTO TABLE lt_elements.
But this really is advanced ABAP, and not suitable for someone who is clearly a beginner. ( Also note that these forums are not supposed to be a substitute for training - or reading an ABAP tutorial ).
matt
Similar Messages
-
Is there arrays or FOR loops in ABAP?
Hi everyone!
Is there an array and FOR loops in ABAP similar to the C Language?
If there is, please give example. _
Thanks a lot!Hi,
There is no array concept in ABAP but there are field-symbols which are same as pointers in C.As for the FOR loop there is no such command in SAP/ABAP but we do have the do..while and loop...endloop commands.There is also CASE statements and if..endif commands.
Thanks,
Sandeep. -
Create new survey data for opportunity using abap code
Hello to all,
I have one requirement.
create survey data for given opportunity ID using abap code. or copy survey data from one opportunity to another opportunity using abap.
any ideas..
many thanks
BabuHello Babu,
You can do this through the CRM_ORDER_MAINTAIN FM, this is the generic FM to edit any transaction in CRM.
The FM contains an internal table IT_SURVEY that must be filled. Actually, this table will only contain a reference to the (completed) survey, it doesn't store the data of the survey itself.
For some example coding, take a look at the SrvTSurvey.do controller. If you want to see what data is stored in the IT_SURVEY table, create a transaction and attach a completed survey to it (you can easily do it in the standard views of the webclient) and take a look at the survey structure in the CRM_ORDER_READ FM/Report.
Let me know if you need more guidance,
Reward points if useful,
Regards,
Joost -
CMOD exit_rsap_saplr_001 for transactional data ABAP CODE
Hi please confirm that you want to convey that i can write the actual code in CMOD exit_rsap_saplr_001 for transactional data?? if i put 20 data sources enhancement code in there is'nt that too bulky and will cause the failing all extractor if one code is wrong if you still suggest that i can go ahead with 20 similar codes as below . please see my code below which i have used for all 20 datasources with little modification
if you can recommend some changes in code to improve performance would be great
case i_datasource.
WHEN '0CUSTOMER_ATTR'.
loop at i_t_data into l_s_BIW_KNA1_S.
l_tabix = sy-tabix.
clear i_knvp.
select single * from KNVP into i_knvp where KUNNR = l_s_BIW_KNA1_S-KUNNR.
if sy-subrc = 0.
l_s_BIW_KNA1_S-ZZPARFN = i_knvp-PARVW.
l_s_BIW_KNA1_S-ZZCUSNOBP = i_knvp-KUNN2.
modify i_t_data from l_s_BIW_KNA1_S index l_tabix.
endif.
endloop.
endcase.
Thanks
PoonamCheck this simple code for Z...include into the FM EXIT_SAPLRSAP_001 where zcomp is new field added into the datasource 8zsales2.
data : l_s_/BIC/CE8ZSALES2 like /BIC/CE8ZSALES2,
l_tabix like sy-tabix.
case i_datasource.
when '8ZSALES2'.
loop at c_T_DATA into l_s_/BIC/CE8ZSALES2.
l_tabix = sy-tabix.
fill the new field
select comp_code from /BI0/MCOMP_CODE into l_s_/BIC/CE8ZSALES2-zcomp
where comp_code = '1000'.
if sy-subrc = 0.
*l_s_ZFIAA_IS001_TXT50 = ANLA_TXT50.
modify c_t_data from l_s_/BIC/CE8ZSALES2 index l_tabix.
endif.
endselect.
endloop.
endcase.
Edited by: Rohan Kumar on Jan 16, 2008 8:21 AM -
Adding mouselisteners to JPanels created through for loop
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileSystemView;
public class ScrollableWrapTest {
public static void main(String[] args) {
try {
ScrollableWrapTest st = new ScrollableWrapTest();
final JPanel mainPanel = new JPanel(new WrapScollableLayout(FlowLayout.LEFT, 10, 10));
mainPanel.setBackground(Color.WHITE);
JScrollPane pane = new JScrollPane(mainPanel);
pane.setPreferredSize(new Dimension(550, 300));
Vector v = new Vector();
v.add("first.doc");
v.add("second.txt");
v.add("third.pdf");
v.add("fourth.rar");
v.add("fifth.zip");
v.add("sixth.folder");
v.add("seventh.exe");
v.add("eighth.bmp");
v.add("nineth.jpeg");
v.add("tenth.wav");
JButton button = null;
for(int i =0;i<v.size();i++){
JPanel panel = new JPanel(new BorderLayout());
Icon icon = st.getIcone(st.getExtension(v.elementAt(i).toString().toUpperCase()));
panel.setBackground(Color.WHITE);
Action action = new AbstractAction("", icon) {
public void actionPerformed(ActionEvent evt) {
button = new JButton(action);
button.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
buttonPanel.add(button);
JLabel label = new JLabel((String)v.elementAt(i));
label.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(buttonPanel , BorderLayout.NORTH);
panel.add(label, BorderLayout.SOUTH);
mainPanel.add(panel);
mainPanel.revalidate();
st.buildGUI(pane);
} catch (Exception e) {e.printStackTrace();}
public void buildGUI(JScrollPane scrollPane)
JFrame frame = new JFrame("Scrollable Wrap Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
public String getExtension(String name)
if(name.lastIndexOf(".")!=-1)
String extensionPossible = name.substring(name.lastIndexOf(".")+1, name.length());
if(extensionPossible.length()>5)
return "";
else
return extensionPossible;
else return "";
public Icon getIcone(String extension)
//we create a temporary file on the local file system with the specified extension
File file;
String cheminIcone = "";
if(((System.getProperties().get("os.name").toString()).startsWith("Mac")))
cheminIcone = System.getProperties().getProperty("file.separator");
else if(((System.getProperties().get("os.name").toString()).startsWith("Linux")))
//cheminIcone = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath()+
cheminIcone = "/"+"tmp"+"/BoooDrive-"+System.getProperty("user.name")+"/";
else cheminIcone = System.getenv("TEMP") + System.getProperties().getProperty("file.separator");
File repIcone = new File(cheminIcone);
if(!repIcone.exists()) repIcone.mkdirs();
try
if(extension.equals("FOLDER"))
file = new File(cheminIcone + "icon");
file.mkdir();
else
file = new File(cheminIcone + "icon." + extension.toLowerCase());
file.createNewFile();
//then we get the SystemIcon for this temporary File
Icon icone = FileSystemView.getFileSystemView().getSystemIcon(file);
//then we delete the temporary file
file.delete();
return icone;
catch (IOException e){ }
return null;
private static class WrapScollableLayout extends FlowLayout {
public WrapScollableLayout(int align, int hgap, int vgap) {
super(align, hgap, vgap);
public Dimension preferredLayoutSize(Container target) {
synchronized (target.getTreeLock()) {
Dimension dim = super.preferredLayoutSize(target);
layoutContainer(target);
int nmembers = target.getComponentCount();
for (int i = 0 ; i < nmembers ; i++) {
Component m = target.getComponent(i);
if (m.isVisible()) {
Dimension d = m.getPreferredSize();
dim.height = Math.max(dim.height, d.height + m.getY());
if (target.getParent() instanceof JViewport)
dim.width = ((JViewport) target.getParent()).getExtentSize().width;
Insets insets = target.getInsets();
dim.height += insets.top + insets.bottom + getVgap();
return dim;
}How can I add mouse listener to each of the 'panel' in 'mainpanel' created inside the 'for loop' using the code mainPanel.add(panel);Rony>
How can I add mouse listener to each of the 'panel' in 'mainpanel' created inside the 'for loop' using the code mainPanel.add(panel);
Change the first part of the code like this..
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileSystemView;
public class ScrollableWrapTest {
public static void main(String[] args) {
try {
ScrollableWrapTest st = new ScrollableWrapTest();
final JPanel mainPanel = new JPanel(new WrapScollableLayout(FlowLayout.LEFT, 10, 10));
mainPanel.setBackground(Color.WHITE);
JScrollPane pane = new JScrollPane(mainPanel);
pane.setPreferredSize(new Dimension(550, 300));
Vector<String> v = new Vector<String>();
v.add("first.doc");
v.add("second.txt");
v.add("third.pdf");
v.add("fourth.rar");
v.add("fifth.zip");
v.add("sixth.folder");
v.add("seventh.exe");
v.add("eighth.bmp");
v.add("nineth.jpeg");
v.add("tenth.wav");
JButton button = null;
MouseListener ml = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent me) {
System.out.println(me);
for(int i =0;i<v.size();i++){
JPanel panel = new JPanel(new BorderLayout());
Icon icon = st.getIcone(st.getExtension(v.elementAt(i).toString().toUpperCase()));
panel.setBackground(Color.WHITE);
Action action = new AbstractAction("", icon) {
public void actionPerformed(ActionEvent evt) {
button = new JButton(action);
button.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
buttonPanel.add(button);
JLabel label = new JLabel((String)v.elementAt(i));
label.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(buttonPanel , BorderLayout.NORTH);
panel.add(label, BorderLayout.SOUTH);
mainPanel.add(panel);
panel.addMouseListener( ml );
mainPanel.revalidate();
st.buildGUI(pane);
} catch (Exception e) {e.printStackTrace();}
... -
How to get out of for loop in eclipse debugging
How to get out of for loop in eclipse debugging for java classes ?
I am in a for loop in a code. i want to get out of it ...but how ?is changing the behaviour of a running class like that really going to be any use for debugging? what's the actual problem?
-
How to make a button to stop and run a for loop?
How to make a button to stop and run a for loop? and if it is stopped it shall start from where i t stopped.
Your VI has some very fundamental flaws.
The start/stop button is outside the FOR loop, thus it will NOT get read during execution of the FOR loop, but only before the FOR loop starts. Think dataflow!
Thus the terminal of the start/stop button belongs inside the FOR loop.
Your FOR loop iterates 20x, which probably takes about a nanosecond. You will NOT be fast enough to reliably press the start/stop button during a specific iteration of the FOR loop.
Your code does not "stop and run" a FOR loop (sic). The loop always spins, but executes an empty case when "Stopped". I guess that's what you actually want?
Once you solve (2), the x indicator will contain a random value whenever you "stop".
As soon as the 20 iterations complete, the outer while loop spin an things start over, another nanosecond later.
Place e.g. a 500ms wait inside the FOR loop to solve this.
Don't place terminals of indicators on top of formula nodes.
Your formula does not produce any output, so really has no purpose.
Use a real "stop" button to terminate the while loop (mechanical action: latch when released). Right now you are using a plain switch, which does not reset to false before the next run. This means that you need to manually reset it before running the program again.
It is oftern useful to operate the VI in execution highlighting mode. You will immediately see that your button does not get read during execution of the FOR loop. Try it!
LabVIEW Champion . Do more with less code and in less time . -
Sample ABAP code for userexits, and calling bapi's
Hi,
Can someone please send me sample ABAP code
1) to do extractor enhancement using user exit.
2) ABAP program to call BAPI to read live cache order series data in SNP and write to Idocs through some ports.
3) ABAP routine to generate file name (based on date/country)in the infopackage to upload flatfiles.
Thank you very much in advance and appreciate any help.
Regards
Prasadhai ,
check this code...
*& Tables
tables : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct. "Transaction Code Texts
*& Variables
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
*& Selection Screen Parameters
selection-screen begin of block a01 with frame title text-001.
selection-screen skip.
parameters : p_tcode like tstc-tcode obligatory.
selection-screen skip.
selection-screen end of block a01.
*& Start of main program
start-of-selection.
Validate Transaction Code
select single * from tstc
where tcode eq p_tcode.
Find Repository Objects for transaction code
if sy-subrc eq 0.
select single * from tadir
where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir
where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir
where pname = tstc-pgmna.
select single * from enlfdir
where funcname = tfdir-funcname.
select single * from tadir
where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name = enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
Find SAP Modifactions
select * from tadir
into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct
where sprsl eq sy-langu
and tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.
Take the user to SMOD for the Exit that was selected.
at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen. -
Schedule a background job for a program using ABAP code.
Hi,
I have to write a program to schedule a background job for another program.
Need your help to understand how we can achieve this functionality.Any example of an abap code would be of great help.
Need it urgently.
Thanks in advance.
Sandeep.Hi Sandeep,
Here is the demo program regarding the BDC For the background job.
report zprprbdc1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
***data: begin of itab occurs 0 ,
*** matnr(20) type c,
*** mbrsh(30) type c,
*** mtart(30) type c,
*** kzsel(20) type c,
*** maktx(40) type c,
*** meins(5) type c,
*** end of itab.
data: begin of record occurs 0,
* data element: MATNR
matnr_001(018),
* data element: MBRSH
mbrsh_002(001),
* data element: MTART
mtart_003(004),
* data element: XFELD
kzsel_01_004(001),
* data element: MAKTX
maktx_005(040),
* data element: MEINS
meins_006(003),
* data element: MTPOS_MARA
mtpos_mara_007(004),
end of record.
*** End generated data section ***
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
**do.
**read dataset dataset into record.
**if sy-subrc <> 0. exit. endif.
call function 'GUI_UPLOAD'
exporting
filename = 'c:\jitu\bdc\10002.txt'
filetype = 'ASC'
has_field_separator = 'x'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = record
* 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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at record .
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-matnr_001.
perform bdc_field using 'RMMG1-MBRSH'
record-mbrsh_002.
perform bdc_field using 'RMMG1-MTART'
record-mtart_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-kzsel_01_004.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
record-maktx_005.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-meins_006.
perform bdc_field using 'MARA-MTPOS_MARA'
record-mtpos_mara_007.
perform bdc_transaction using 'MM01'.
**enddo.
endloop.
perform close_group.
*perform close_dataset using dataset.
&*****************Reward point if helpful************& -
ABAP Code in Start Routine for restricing the data records from ODS1 - ODS2
Hi
I need small ABAP Code in Start Routine Of Update rules Of ODS . Im in BW 3.5 .
I have records like below in first layer ODS and i want to restrict some records while going to second layer ODS ..
ODS1 :-
DocNO EventType Date
123 001 08/08/2008
123 003 08/08/2008
123 011 09/08/2008
I want one record in ODS2 for this document number whose EventType = 001 only and date of third record ... like below
Doc NO EventType From Date Todate
123 001 08/08/2008 09/08/2008
So how can i get like this record in the ODS2 which will get data from ODS1 . So i need to write the code in the start routine of the ODS2 .
So please give the me the code for start routine ....
Regards
SureshIts difficult in BW 3.5 to include this logic in START_ROUTINE as you cannot add the extra to_date field to the DATA_PACKAGE table.
You need to create a new global internal table with the same structure of DATA_PACKAGE with additional field to_date. then use the logic to fill in the global internal table
define a internal table new_data_package with the required structure like (docno, eventtype, fromdate todate)
data: l_w_datapkg_001 type data_package,
data: l_w_newdatapkg type new_data_package,
data: l_w_datapkg_011 type data_package
LOOP AT DATA_PACKAGE INTO l_w_datapkg_001 WHERE event_type = '001'.
l_w_newdatapkg-docno = l_w_datapkg_001-docno.
l_w_newdatapkg-event_type = l_w_datapkg_001-event_type.
l_w_newdatapkg-fromdate = l_w_datapkg_001-date.
MOVE CORRESPONDING FIELDS OF l_w_datapkg_001 INTO l_w_newdatapkg.
READ TABLE data_package INTO l_w_datapkg_011
WITH KEY docno = l_w_datapkg_001-docno
event_type = '011'.
l_w_newdatapkg-to_date = l_w_datapkg_011-date.
APPEND l_w_newdatapkg TO new_data_package
ENDLOOP.
Now the new datapackage contains the ODS2 data that u needed -
Hi Gurus;
Can some one send me the abap codes used mainly for reporting OR can some one give me some sample code used in reporting. my mail id "[email protected]".smod > rsr0001 > EXIT_SAPLRRS0_001 > ZXRSRU01 >
CASE I_VNAM.
WHEN 'ZE_FPPT'.
CALL FUNCTION 'Z_VAR_FP4'
EXPORTING
I_VNAM = i_vnam
I_STEP = i_step
I_T_VAR_RANGE = I_T_VAR_RANGE
IMPORTING
E_T_RANGE = E_T_RANGE.
FUNCTION Z_VAR_FP4.
""Local Interface:
*" IMPORTING
*" REFERENCE(I_VNAM) LIKE RSZGLOBV-VNAM
*" REFERENCE(I_STEP) TYPE I DEFAULT 0
*" REFERENCE(I_T_VAR_RANGE) TYPE RRS0_T_VAR_RANGE
*" EXPORTING
*" VALUE(E_T_RANGE) TYPE RSR_T_RANGESID
data: l_s_range type rsr_s_rangesid.
data: LOC_VAR_RANGE LIKE RRRANGEEXIT.
data: year(4).
data: mth(2).
IF I_STEP = 2 .
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE
( VNAM = '0I_FPER' ).
year = LOC_VAR_RANGE-HIGH+0(5).
mth = LOC_VAR_RANGE-HIGH+5(2).
if mth < 10.
concatenate '0' mth into mth.
endif.
concatenate year '0' mth into L_S_RANGE-HIGH.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
ENDLOOP.
ENDIF.
ENDFUNCTION.
Regards,
BWer
Assign points if helpful.
Message was edited by: BWer -
Hi All,
I have requirement to write code for date range.
Characterstic = Run-Out Date, it was created reference to 0Date.
Requirement is data should load depends on Run-Out Date 7 days old and 14 days future.
Logic is -7 days old >= Run_out date <= 14 days future.
please let me know how I need to proceed with ABAP code for this requirement.
Thanks.
Please do not ask for ABAP code here. Its not a training forum
Edited by: Pravender on Aug 18, 2011 1:46 AM>
Sree vignesh wrote:
> Hi,
> In the select option we have a field month range as
> SELECT-OPTION : FROM 01.2007 TO 01.2009 " Let say Ur Selection option is SO_MONTH
> but now i need to add the DMBTR field considering the month range in the SELECT OPTION i.e., only FROM 01.2007 TO 01.2009 i mean without 2006 data.
>
> LOOP AT LT_DATA WHERE month in SO_MONTH. " Here add a Where condition
> ls_output-matnr = lt_data-belnr.
> ls_output-werks = lt_data-bukrs.
> ls_output-lgort = lt_data-dmbtr.
>
> COLLECT ls_output INTO lt_output .
>
> ENDLOOP.
>
> please help with code .
>
> thanks in advance.
Regards,
Suneel G -
ABAP Code Date Selection for InfoPackage Scheduler
Hello Group
I need to automate the selection of valid condition records for an extraction that have a From and To date range.
I noticed there is an option (Routine for time interval) to write ABAP code along with a template that is available in the InfoPackage.
I think the logic for the selection would be any record
Valid from <= today
Valid to >= today
Can anyone help with the ABAP code?
The template is as follows:
program conversion_routine.
Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rsldpsel.
Global code used by conversion rules
$$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: ...
$$ end of global - insert your declaration only before this line -
form compute_time_dependent_dates
changing p_datefrom type d
p_dateto type d
p_subrc like sy-subrc.
Insert source code to current selection field
$$ begin of routine - insert your code only below this line -
p_datefrom =
p_dateto =
p_subrc = 0.
$$ end of routine - insert your code only before this line -
endform.
Thank You for your help!!
FrankI resolved the problem . I have changed the order of read table l_t_range because I need the header .
In the loop at datos I add the line l_t_range-iobjnm = 'ZXGE_UNO'.
The problem wasn't the call RFC it was that I built l_t_range bad. I need the infoObject name.
This is correct!!
READ TABLE L_T_RANGE WITH KEY
FIELDNAME = '/BIC/ZXGE_UNO'.
LOOP AT DATOS.
L_T_RANGE-FIELDNAME = '/BIC/ZXGE_UNO'.
L_T_RANGE-IOBJNM = 'ZXGE_UNO'.
L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'EQ'.
CONCATENATE '00' DATOS-WA+3(4) INTO L_T_RANGE-LOW.
APPEND L_T_RANGE.
ENDLOOP.
*READ TABLE L_T_RANGE WITH KEY+
+*FIELDNAME = '/BIC/ZXGE_UNO'.+
+* L_IDX = SY-TABIX.+
+* MODIFY L_T_RANGE INDEX L_IDX
Thanks a lot
Ana -
I want to make a validation for callup point 3 'Complete Document'
I would like a validation in bool_data-bseg that only 1 transaction type (bewar) or no transaction type is used in any of the line items. If 0 or only 1 transaction type has been used there is no error. If more than 1 transaction type is used in the line items then an error message should appear that only 1 transaction type should be used.
ABAP Code would be roughly:
LOOP AT bool_data-bseg INTO bseg WHERE bewar <> ''.
ENDLOOP
if bewar_count >1
b_result=false.
else .
b_result=true.
end if.
Please give some hints for the code at '...'.Moderator message - Essentially duplicate post locked
Rob -
ABAP Code for Extractor Enhancement
Hi Gurus,
I enhanced the datasource 0CO-OM_CCA_9. My requirement is to pull the data from COKP (line item table) to COEP (header table). The extract structure will then pull the data from COEP. I wrote an ABAP code but its not working for me. Can you please suggest me some options.
Thanks,
NaineeshHi,
See SAP Help
http://help.sap.com/saphelp_nw04s/helpdata/en/6e/fe6e420f00d242e10000000a1550b0/content.htm
See the simple example code, so follow the same.Take ABAPer help.
CASE i_datasource.
Data: l_s_data1 LIKE mc13vd0itm,
l_tabix LIKE sy-tabix,
WHEN '2LIS_13_VDITM'.
LOOP AT c_t_data INTO l_s_data1.
l_tabix = sy-tabix.
SELECT SINGLE auart INTO l_s_data1-zzprdtyp FROM vbak
WHERE vbeln = l_s_data1-aubel.
IF sy-subrc = 0.
MODIFY c_t_data FROM l_s_data1 INDEX l_tabix.
ENDIF.
ENDLOOP.
ENDCASE.
See article on Step by Step Guide to Enhance a Data Source:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00c1f726-1dc2-2c10-f891-ddfbffdb1a46?quicklink=index&overridelayout=true
Thanks
Reddy
Maybe you are looking for
-
Upload flat file to a variable when creating a variant or broadcast setting
Hello Experts, Our users have recently begun to use the Broadcast E-Mail (Bursting) settings. On the Recipient Determination tab, some settings have the "Selection of Characteristic Values" set to "By Following Selection" and some have it set to "By
-
New Mighty Mouse have better scrollwheel?
The new iMacs ship with a new mighty mouse -- anyone know if there's changes to the scroll wheel so it won't get dirty as easily? http://usage.wordpress.com/2007/08/14/apple-quietly-updates-mighty-mouse/
-
Hi All - We are planning to go for CUCM direct upgrade from 7.1.3 - 9.1.2 Also for UCCX from 7.0.1 SR5 ---> 8.5.1 --> 8.5.1 SU3 --> 9.0.2 During upgarde of UCCX 8.5.1 on UCS Machine it will ask to eneter CUCM AXL user Credentails which is in 9.1.2, S
-
What is mac's version of word ?
what is mac's version of word ?
-
Gentlemen, First of all I want to say I'm not that young. I've shared with the Adobe community for 10 years now and now I need your help. Inititally I posted my question in Russian, but no one could help me. Yesterday I bought both of Kahrel's .pdfs