2

I don't have any developer rights in my SAP-System but I found a way to write some ABAP-Code in a tiny "User-Exit" box (I don't know if that's what you call it) inside a report.

I'm trying to submit a HR-Report and plug it's outcoming PERNR into that same report again.

There's a syntax-error that is telling me that t_list doesn't have a component with the Name PERNR.

What do I have to do in order to get this to work?

DATA: t_list TYPE TABLE OF abaplist WITH HEADER LINE,
      seltab TYPE TABLE OF rsparams,
      selline LIKE LINE OF seltab.
*I found out that the name of the selection field in the Report-GUI is "PNPPERNR" and tested it
selline-selname = 'PNPPERNR'.
selline-sign    = 'I'.
selline-option  = 'EQ'.

SUBMIT Y5000112
USING SELECTION-SET 'V1_TEST'
EXPORTING LIST TO MEMORY
AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
  listobject = t_list
EXCEPTIONS
  not_found = 1
  OTHERS = 2.
IF sy-subrc <> 0.
  WRITE 'Unable to get list from memory'.
ELSE.
  LOOP AT t_list.
*The Problem is here: how do I get the pnppernr out of t_list, it's the first column of the report output
    selline-low = t_list-pernr.
    append selline to seltab.
  ENDLOOP.

  SUBMIT Y5000112
  WITH SELECTION-TABLE seltab
  USING SELECTION-SET 'V2_TEST'
  AND RETURN.
ENDIF.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Cold_Class
  • 3,214
  • 4
  • 39
  • 82

2 Answers2

3

Use the function module LIST_TO_ASCI to decode the contents of t_list into something readable. This answer contains some sample code including the data types required. At this point, the data you're looking for will probably occur at the same column range in the output. Use the standard substring access methods - e. g. line+42(21) to obtain the part of the line you need.

Community
  • 1
  • 1
vwegert
  • 18,371
  • 3
  • 37
  • 55
0

The vwegert's answer is more than useful!
In my previous answer I forgot to mention LIST_TO_ASCI FM :) The only thing I can add is that parsing of result lines has no universal solution and greatly depends on its structure. Usually it is done like:

LOOP AT t_list.
 SPLIT t_list AT '|' INTO <required_structure>.
 selline-low = <required_structure>-pernr.
 APPEND selline TO seltab.
ENDLOOP.

where <`required_structure> is your Y5000112 output structure. But this may be not so simple and may require additional manipulations.

Community
  • 1
  • 1
Suncatcher
  • 10,355
  • 10
  • 52
  • 90