ABAP free internal table [closed] - refresh

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
The answer to the question below is given as 2. Why does refresh delete only the first row? Is it not expected that it deletes all rows of an internal table?
What will be output by the following code?
DATA: BEGIN OF itab OCCURS 0, fval type i, END OF itab.
itab­-fval = 1. APPEND itab.
itab­-fval = 2. APPEND itab.
REFRESH itab.
WRITE: /1 itab­-fval.
A: 1
B: 2
C: blank
D: 0
Answer: B

If the code did not contain any syntax errors, e.g. the missing '-' when assigning the value 2 and when writing the value, then B is the correct answer but not for the reason you state. It is not that the REFRESH only removes the first line from the table, it is because REFRESH does not clear the header line of the table. So after the REFRESH the header line still has the latest assigned value which is 2. This can be easily ascertained when running the program in the debugger.
Note that the use of internal table with header lines is obsolete, as mentioned in SAP help.

You can use a clear command to clear the header line.
REFRESH itab.
CLEAR itab.

Related

the item that repeated a specified number of times in spark (scala) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
I want to know the items that repeated a specified number of times in Spark (Scala).
With an RDD like this:
rdd = [text1,text2,text3,text4,text2,text4,text1,text1]
if the time = 2 the output should be [text2,text4].
Say you have an RDD that has been created like this:
val df: RDD[String] = spark.sparkContext.parallelize(Seq(
"text1", "text2", "text3", "text1", "text2", "text4"
))
You can use countByValue followed by a filter and keys, where 2 is your time value:
df.countByValue().filter(tuple => tuple._2 == 2).keys
If we do a println, we ge the following output:
[text1, text2]
Hope this is what you want, good luck!

How to return all value out the for loop in golang [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
In python I can return how value what I append in the array
valuesinPy= []
for i range(len(value)) :
valuesinPy.append(value[i])
return valuesinPy
It's able to return all value I want to append in golang
valueappend =make(map[strig]string)
for i :=range value{
valueappend['abs']=value[i]
}
return valueappend
it's all same
But the value return same I got confused
Problem fix
I use the map [string]interface{}{} I less one struct of slice
valueappend:=map[string]interface{}{}
for i :=range value{
valueappend= append(valueappend, map[string]interface{}{
"valueIwant append" value[i] :
}
}
return valueappend
One issue I can see is that the key you are using is same in all iterations of the loop
valueappend['abs']=value[i]
This will overwrite all previous values and you will only have the last one in the loop be saved. In the end you will get a map with just one value. I'm guessing that's not what you want here. Use can use a unique key for each iteration as follows, or something else along the same line
for i := range value {
valueappend[i]=value[i]
}
#范紀予 please add more info and clarify what you are trying to achieve here.
You'll probably need to change the value of the map each time you go through the loop, or else every value from value[i] will keep writing to that same field in the map, leaving with the last value of i as your only value in the map

How can I determine a state with a given zip code in Stata? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Currently, my line of code is really long and I was curious to know if there was a more efficient way of doing this.
As Nick has pointed out your question is missing most of the information that would make it answerable. Please read more here, and add more information to your question.
In the meantime, a useful approach is to merge your zipcode data with a dataframe (or dataset) with the state-zipcode link in it.
* first you need to get the zipcode data from somewhere.
* Here is one way:
!wget "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt"
* now put this data in a frame
frame create zctaFrame
frame zctaFrame{
import delimited "zcta_county_rel_10.txt"
}
* now I'm making up a dataset (share some of yours with dataex from ssc
input str10 name zip
"sam" 55901
"sasha" 84101
"saul" 84111
end
frlink 1:1 zip, frame(zctaFrame zcta5)
frget state, from(zctaFrame)
If this doesn't match what you're trying to do, please add more detail to the question.

Stepfunction map with condition [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there is any possibility to run the was step function map Iterator based on the condition Am going to invoke the lambda and based on the result I have to choose the input item of the iteration meaning if there is an array of 0-3 items once the first item executes with lambda then based on the result it should execute 1st index or 2nd index item.
The other option is to create a while loop like this:
Set a variable to track your index (pos = 0)
Do whatever you want to do inside your iteration also you could use some condition, if you want to process each item conditionally
increase your index ( pos++)
If your index is less that your items count go to step1.
This way you have access to the result of previous iteration, so you can fine tune your condition.

Changing one value of row to column [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am working on a Power BI report. There are two dimensions DimWorkedClass and DimWorkedService. (The above snippet is obtained by exporting matrix values to csv.)
The requirement is to transform only the Worked Service Text5 into the Worked Class of Text5 as opposed to A (which is the current value).
It can be transformed at the backend, but is there any way to do it in Power BI?
This is trickier than it might appear, but it looks like this question has already been answered here:
Power Query Transform a Column based on Another Column
In your case, the M code would look something like this:
= Table.FromRecords(Table.TransformRows(#"[Source or Previous Step Here]",
(here) => Record.TransformFields(here, {"Worked Class",
each if here[Worked Service] = "text5" then "text5" else here[Worked Class]})))
(In the above, here represents the current row.)
Another answer points out a slightly cleaner way of doing this:
= Table.ReplaceValue(#"[Source or Previous Step Here]",
each [Worked Class],
each if [Worked Service] = "text5" then "text5" else [Worked Class],
Replacer.ReplaceText,{"Worked Class"})