ABAP Report Logic - abap

I am new to ABAP.
I have a requirement in abap.In my presentation server ,there is header text file, which I want to upload data from that text file to Header table. But the custom table is having different structure from text file.
It includes extra 4 fields- PO_CREATED_DATE, PO_CREATED_BY, PO_CHANGED_DATE, PO_CHANGED_BY.
These fields have to populate from our report program using sy-datum and sy-uname.
In this scenario,we have to check,If the data is existing then populate
PO_CHANGED_DATE, PO_CHANGED_BY and if the data is not there,then populate PO_CREATED_DATE, PO_CREATED_BY.
Please let me know the logic...

first load the file into an internal table with only 1 very long field (long enough to contain at least the longest possible line in the file). Then loop over that itab and split the individual lines using the separator that is used in the file. You split the contents into a work area that contains all your fields, including the 4 extra fields that may or may not be included in the file. Make sure to clear the work area before splitting the line into the WA. Append the work area to an itab with the same structure as the wa, then continue with the next line.
After that, loop over that second itab and check for lines where your 4 extra fields are initial. Those are the lines where you need to add the data by code. After that, do whatever you need to do with the data in the itab.

I uploaded text file header data to it_input1 using gui_upload.But the it_input1 is not having extra 4 fields.I declared another itable it_header which is having the same structure as Header custom table.Now i wnt to check whether the data in the it_input 1 is alredy existing or not.If existing ,populate it_header-po_changed_date and it_header-po_changed_by or else, it_header-po_created_date and it_header-po_created_by.

Take a look to the "Pattern" Button on top. Select ABAP Objects an press enter.
Now you can supply the class and methdo you want to call.
CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
GUI_UPLOAD is a static method. If you are new that is the easiest way to see which parameters must be supplied. With the forward navigation (double-click) you can check the signature for typing the parameter variables.
Then you just need to convert your data (e.g. SPLIT). I can only recommend to use the F1-Help.
Kind regards!

Related

LabVIEW Inserting/overwriting text into existing string

I was wondering if folks have found a reliable way to inject text into an existing string. Some context, I'm writing data to a string indicator formatted like a table, and I wanted to inject values into so they maintain a specific format, spacing-wise. Writing to a table would definitely be easier, however I am porting a legacy program and wanted to provide familiarity to the end user.
Essentially, I want to do the equivalent of typing into a .txt file with the INSERT function enabled, where it just overwrites the content already in the string. Example below (dashes added to show spacing) of how it is currently looking when I inject the values with hard coded spacing:
Time---value---avg. value---result
60------10---------20---------PASS
120------11---------20---------PASS
180------9---------15---------FAIL
I'd prefer it to look more lined up, like below:
Time---value---avg. value---result
60------10---------20---------PASS
120-----11---------20---------PASS
180-----9--------- 15---------FAIL
Writing my application using LabVIEW 2019
Edit: Header will obviously not change, only each subsequent line where the values can result in entries not looking lined up
What about "Replace Substring" function (https://zone.ni.com/reference/en-XX/help/371361R-01/glang/replace_substring/)? Doesn't it meet your requirements?
The diagram below outputs 01234999990123PASS890123456789. The values of the integer and the word PASS are added replacing characters in the existing string, exactly like overstrike would do.

Passing the data from the structure into the table

I am trying to pass data from a work area to a table. The idea is that I have declared the elements from the Screen Painter as data from a structure, e.g. The field with the name Banks would be as gs_zfr_bn-bankl, where the structure would be declared in the report as gs_zfr_bn TYPE zfr_bn, where zfr_bn is an global table.
Now I am trying to create a form which would serve to pass the data from the structure to the table, where the form would be activated from the event of pressing a button in the selection screen. I have been trying to create a code for that, however I am having an error. The code to pass the data is shown as follows:
DATA: gt_zfr_bn TYPE TABLE OF zfr_bn.
LOOP AT gt_zfr_bn INTO gs_zfr_bn.
APPEND LINES OF gs_zfr_bn TO gt_zfr_bn.
ENDLOOP.
The error is that gs_zfr_bn is not an internal table and the append would not work.
Is there any way to pass the data from the structure into the table gt_zfr_bn, be that hard coded or via an method?
Thank you all in advance!
You mention that you already using gs_zfr_bn structure in screen paint. So you don't need to re-declare it. Just append structure to itab.
APPEND gs_zfr_bn TO gt_zfr_bn.
Just use APPEND without the LINES OF:
APPEND gs_zfr_bn TO gt_zfr_bn.
(APPEND LINES OF ... this would append the lines of one internal table to another.)

Get Text Symbol Programmatically With ID

Is there any way of programmatically getting the value of a Text Symbol at runtime?
The scenario is that I have a simple report that calls a function module. I receive an exported parameter in variable LV_MSG of type CHAR1. This indicates a certain status message created in the program, for instance F (Fail), X (Match) or E (Error). I currently use a CASE statement to switch on LV_MSG and fill another variable with a short description of the message. These descriptions are maintained as text symbols that I retrieve at compile time with text-MS# where # is the same as the possible returns of LV_MSG, for instance text-MSX has the value "Exact Match Found".
Now it seems to me that the entire CASE statement is unnecessary as I could just assign to my description variable the value of the text symbol with ID 'MS' + LV_MSG (pseudocode, would use CONCATENATE). Now my issue is how I can find a text symbol based on the String representation of its ID at runtime. Is this even possible?
If it is, my code would look cleaner and I wouldn't have to update my actual code when new messages are added in the function module, as I would simply have to add a new text symbol. But would this approach be any faster or would it in fact degrade the report's performance?
Personally, I would probably define a domain and use the fixed values of the domain to represent the values. This way, you would even get around the string concatenation. You can use the function module DD_DOMVALUE_TEXT_GET to easily access the language-dependent text of a domain value.
To access the text elements of a program, use a function module like READ_TEXT_ELEMENTS.
Be aware that generic programming like this will definitely slow down your program. Whether it would make your code look cleaner is in the eye of the beholder - if the values change rarely, I don't see why a simple CASE statement should be inferior to some generic text access.
Hope I understand you correctly but here goes. This is possible with a little trickery, all the text symbols in a report are defined as variables in the program (with the name text-abc where abc is the text ID). So you can use the following:
data: lt_all_text type standard table of textpool with default key,
lsr_text type ref to textpool.
"Load texts - you will only want to do this once
read textpool sy-repid into lt_all_text language sy-langu.
sort lt_all_Text by entry.
"Find a text, the field KEY is the text ID without TEXT-
read table lt_all_text with key entry = i_wanted_text
reference into lsr_text binary search.
If you want the address you can add:
field-symbols: <l_text> type any.
data l_name type string.
data lr_address type ref to data.
concatenate 'TEXT-' lsr_text->key into l_name.
assign (l_name) to <l_text>.
if sy-subrc = 0.
get reference of <l_text> into lr_address.
endif.
As vwegert pointed out this is probably not the best solution, for error handling rather use message classes or exception objects. This is useful in other cases though so now you know how.

Filling parameter with value from Zeconfig_var table

I have the following selection parameter:
PARAMETERS: p_ver(2) AS LISTBOX VISIBLE LENGTH 5.
I would like to populate it with the results from a ZECONFIG_VAR table.
At what point would I do this. Selection Screen Output, Start of Selection, or other. I am trying to allow users the ability to decide what version of the web service they would like to call. The config table will have different url's for the different versions.
I have looked at this Answer and the tutorial provided does not make sense to me.
I would do it at the event INITIALIZATION
However, it may be even easier to just create a search-help, and assign it to p_ver using the following:
parameters: p_ver(2) visible lenghth 5 MATCHCODE OBJECT zshelpname.
Esti is right that you probably want to fill an internal table from the DB table during INITIALIZATION.
But to the populate the listbox parameter, you need to put the call to VRM_SET_VALUES in AT SELECTION-SCREEN OUTPUT.

JMeter CSV Dataset Config: how to move through variables in the same thread?

I'm using a CSV dataset config element, which is reading from a file like this:
abd
sds
ase
sdd
ssd
cvv
Which, basically, has a number of 3 letter random string.
I'm assigning them to a variable called ${random_3}.
Now, I want to use values from this list multiple times within the same thread, but each time I want to move to next. For example, I want the first sampler to use abd, the 2nd to use sds, then ase, etc. But if I just use ${random_3} then only the first one (abd) is used wherever it's referred to. Is there a way I can specify to loop through the values from the CSV dataset within a thread?
CSV Data Set Config works fine for this. All of the values need to be in one column in the file and assign them to the variable as described.
Create a Thread Group that has as many threads for as many users as you want iterating over the file (i.e. acting on the HTTP Request). Assuming 1 user, set the number of threads to 1, loop count to 1.
Inside the thread group you will need to add a Loop Controller or a While Controller. You indicated that you want to loop through the whole data set. If you add a loop controller you will want to set the Loop Count to 6, since you have 6 values, one for each value. Alternately (and easier for processing the whole file) add a While Controller instead of a Loop Controller and set ${random_3} as the while condition.
It is important to set the CSV Data Set Recycle on EOF and Stop Thread on EOF values correctly. If you plan to iterate over the file more than once you must set "Recycle on EOF" to True (i.e. instruct jMeter to move back to the top of the CSV file). Set "Stop Thread on EOF" to False if you are using a loop controller, true if you are using a while controller and want to stop after reading the whole csv dataset.
Add the CSV Data Set Config as a child of the controller along with the HTTP Request. View the results using any listener you want to use.
CSV data set moves through file only when each thread iteration starts.
You can use Raw Data Source PreProcessor to move throuhg file with each request, that's your solution.
Note that you need to have the values for a given variable name in the same column.
Doing: abd sds ase sdd ssd cvv is very different from
abd
sds
ase
sdd
ssd
cvv
The first has 6 variables with one value each; the second has one variable with 6 values.
Update:
CSV Dataset does not seem to be a suitable too for this purpose.
I ended up creating some simple beanshell scripts that create a random 1, 2, or 3 letter word as needed, and also another one that reads a random words from a large set. This way, each time they are called they give a random value. They are called like this:
${__BeanShell(getRandomStr(3))}
or
${__BeanShell(getRandomWord())