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

Need ABAP code for string calculation in BW for master data text

Former Member
0 Likes
364

Hi all,

I have a requirement in my SAP BW to update a master data text for an Info Object with existing master data of an info object with some arithmetic operation on string.

ZMATERIAL has the following attributes :

ZPRODH

ZMVGR2

ZMVGR3

ZSOLMC

ZPRODH is composed :

ZSOLMC + ZMVGR3 + ZMVGR2

Even your text is equal to : Text(ZSOLMC) + u201C u201D + Text (ZMVGR3) + u201C u201D + Text (ZMVGR2)

We need to add a new attribute u201CZMVGR2Tu201D (long as u201CZMVGR3u201D Info Object ) with the following logic to load it :

ZMVGRT = RIGHT(Text(ZPRODH; length (Text (ZPRODH)) - length (Text(ZSOLMC) + length (Text (ZMVGR3) + 2)))

An Example :

A B C D

1 InfoObject KEY Text Length

2 ZPRODH E002E06 Eva flip-flop Replay&Sons SUMMER JR 35

3 ZSOLMC E Eva flip-flop 13

4 ZMVGR3 002 Replay&Sons 11

5 ZMVGR2T E06 SUMMER JR remaining

The formula to value ZMVGR2 is : RIGHT(C2;D2-(D3D42))

I have a logic written here below...

zprodh = in input

zprodh_l = zprodh.length();

zsolmc = zprodh.Substring(0, 1);

zmvgr3 = zprodh.Substring(2,3);

zprodh_t = select text

from zprodh_texts_table

where zprodh_key = zsolmc;

zsolmc_t = select text

from zsolmc_texts_table

where zsolmc_key = zsolmc;

zmvgr3_t = select text

from zmvgr3_texts_table

where zmvgr3_key = zmvgr3;

if(zprodh_t == NULL || zsolmc_t == NULL || zmvgr3_t == NULL) {

zmvgr2t = NULL

} else {

zprodh_t_l = length(zprodh_t);

zsolmc_t_l = length(zsolmc_t);

zmvgr_t_l = lenght(zmvgr3_t);

zmvgr2t = zprodh_t.Substring(zprodh_t_l - (zsolmc_t_l + zmvgr3_t_l + 2), zsolmc_t_l + zmvgr3_t_l + 2);

}

Anybody can explore the logic in SAP ABAP code will help me alot.

Thanking you all in adv

Ajay

1 REPLY 1
Read only

Former Member
0 Likes
305

issue got resolved by self.