Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Applying substring to internal table

0 Likes
1,528

Hello,

I have the following selection into internal table.

SELECT SINGLE sobid

FROM hrp1001

INTO @wa_hrp1001-var_sobid

WHERE otype = 'O'

AND plvar = '01' AND relat = '011'

AND endda GE '99991231'

AND subty = 'A011'

AND sclas = 'K' AND objid = @wa_hrp1001-var_objid.

This produces the output: 0000555559999.

I would like to remove the leading 0 and 9999. I have removed leading 0 by SHIFT wa_hrp1001-var_sobid LEFT DELETING LEADING '0'. I can remove the 9999, in a test, by giving a value with:

DATA: str TYPE string VALUE '555559999.

str = substring( val = str off = 0 len = strlen( str ) - 4 ). write: str.

My question is, how do I loop or incorporate this into that column of data.

3 REPLIES 3
Read only

Abinathsiva
Active Contributor
0 Likes
1,263

Hi,

use LIKE '%555%' this will help your requirment

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,263

I don't understand the question. SOBID is 45 characters. Maybe your question is:

  • Remove all characters from 11th character included (to remove "9999" in your example)
  • Then remove leading zeroes

If yes, that would be: (read ABAP doc SQL String Functions for more information)

SELECT SINGLE ltrim( left( sobid, 10 ) , '0' ) AS sobid ...

NB: don't you have native ABAP functions to operate directly on SOBID value? (like WRITE or a function module) It seems that there are many questions around HRP1001-SOBID, did your read the answers?

Read only

0 Likes
1,263

Thank you Sandra and S Abinath. Information provided was very helpful.

Brian