cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

write subroutine to remove single space after string

Former Member
0 Likes
2,749

Hi Expert,

I am loading Master Data for Inventory , but due to space after my Material record (eg . Correct record - L20233 Error record - "L20233 " ) space sfter 3 charector . it is throughing me error. after edting records in PSA i am able load it further to 0material . Can anyone please help me in writing routine at Transformation level to remove space while loading . Step by step approach is highly appreciated.

Accepted Solutions (0)

Answers (10)

Answers (10)

Former Member
0 Likes

Joe ,

i have implemented start routine and it is working perfectly for loading data stage, But it is not able to delete records which is already exists. Probable reason it PERTICULAR MATERIAL USED AT SEVERAL PLACES is it correct ? --- 1

finally i have decided to add extension to material as original material suppose W02005 . Then while loading it will remove space from behind and add DONOTUSE to it so final it looks like W02005DONOTUSE .

suggest me how can i achieve this with routine point of view. ---2

Please guide me on both points .

Former Member
0 Likes

i have implemented start routine and it is working perfectly for loading data stage, But it is not able to delete records which is already exists. Probable reason it PERTICULAR MATERIAL USED AT SEVERAL PLACES is it correct ? --- 1

Regarding this try checking if the keys you're comparing to delete the records is correct

finally i have decided to add extension to material as original material suppose W02005 . Then while loading it will remove space from behind and add DONOTUSE to it so final it looks like W02005DONOTUSE .

Regarding this point, this can be achieved easily in the routine itself. Just check the length of the material field and append this based on your condition.

You can append like this


concatenate material 'DONOTUSE' into materlal.

Hope this is what you are looking for.

Regards,

Joe

Former Member
0 Likes

Joe,

i am writting this code in Start Routine of Transfer Rule.

i have changed dataPak to Data_Package . but it shows me below error in code ...

The field "DATA_PACKAGE" is unknown, but there are the following fields

with similar names: "DATAPAK" and "L_S_DATA_PACKAGE_LINE".

Please check it and write step by step code which will help me in understand flow as first condense and then remove duplicate record.

Thanks Joe.

Former Member
0 Likes

Hi,

If you are writing it in the start routine of the transfer rules i guess it would be DATAPAK

But I suggest, leave the condense code as it is.

And just add the delete statement in the START ROUTINE OF THE UPDATE RULE.

Because the code otherwise if fine.

And I am normally used to writing my code in the UPDATE RULE

This should remove your duplicate records.

Regards,

Joe

Edited by: lazarus_joey on Feb 21, 2012 2:52 PM

Edited by: lazarus_joey on Feb 21, 2012 3:03 PM

Former Member
0 Likes

thanks joe for yor promt replies..this is urgent..

my Datila as below,

Data Source name - Z_MAT_MASS

field name - /BIC/Z_MAT_MASS

we already used condense statement as below -

condense /BIC/Z_MAT_MASS.

Pleease provide me your step by step code to remove duplidate after condense statement.

This will help me and others i n future..

Thanks a lot ...

Former Member
0 Likes

after condense statement write this to reomve duplicates.

DELETE ADJACENT DUPLICATE FROM SOURCE_PACKAGE COMPAIRING /BIC/Z_MAT_MASS.

Former Member
0 Likes

Thanks for reply ..

i need what code i have to write in LOOP ..

please can you send me step by step code so that it is easy for me to understand.

High point for sure.

Former Member
0 Likes

it is 3.x flow right?

Former Member
0 Likes

Yes ..it is 3.5 SAP Bw flow..

Edited by: Ganesh Bhosale on Feb 21, 2012 5:10 AM

Former Member
0 Likes

Joe,

i have wriiten below code please check it and if you need change it and update ..

DATA: l_s_datapak_line type TRANSFER_STRUCTURE.

loop at datapak into l_s_datapak_line.

condense l_s_datapak_line-/BIC/Z_MAT_MAS.

modify datapak from l_s_datapak_line index sy-index transporting /BIC/Z_MAT_MAS .

clear l_s_datapak_line.

endloop.

if datapak[] is not initial.

sort datapak by /BIC/Z_MAT_MAS.

delete adjacent duplicates from datapak comparing /BIC/Z_MAT_MAS.

endif.

Note - when i am triggering Infopackage then it shows me Yello status and not upadeting to data target..check above code.. Thanks

Former Member
0 Likes

the code the syntax and logic wise looks fine,

but where are you writing it? in the update rules i hope.

and datapak -> should be "DATA_PACKAGE" if you are writing in the update rules.

Try doing it...

Joe

Former Member
0 Likes

Thanks for your prompt reply,

As i am BI Consultant , Can you please send me step by step code to achieve my requirement .that could be excelent for me.

i guess here we have to write loop statement also ,,, and i dont understtande data Package what parameter we have to provide here ...

Please send me code for same to remove one of duplicate data record in Transfer routine.

Thanks..

Former Member
0 Likes

Hi,

You just have to add the foll code in your start routine.


LOOP AT DATA_PACKAGE INTO TO WORK_AREA.
* write your routine for the field here.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING KEY_FIELDS.

since i do not know your exact data source and field.

I can only give you the sample

Try writing with your field names

Regards,

Joe

Former Member
0 Likes

I have written code at field level as ,

Result = Tran-strature-/bic/matnr.

condense no-gaps.

But , In PSA i have two records comming from source system . 1. Correct record 2. same record but haviing space behind it (that space i am removing with the help of above code) but in Infoobject it shows Duplicate Data Records .(because it is having corrct record and Condensed record.

Can any one please help me in code for ,

1. Condense Record -- so that it will remove space AS ABOVE I HAVE WRITTEN.

Note - after first step we will carry two records with same identity . - correct record and condensed.

2. I need Code for transfer rouitne to TO REMOVE DUPLICATE ADJESENT RECORD.

Former Member
0 Likes

You may have to write the code in the update rules - start routine


DELETE ADJACENT DUPLICATES
                   FROM DATA_PACKAGE
                   COMPARING YOUR_KEY

Regards,

Joe.

Former Member
0 Likes

If you need transformation level solution for this,

you can write a field routine for 0material as follows.

use a "formula" Rule type

and use "R_TRIM Delete End Spaces"

i.e. your formula would be something like

R_TRIM(/BIC/XXXXXX)	 

Here /BIC/XXXXXX would be your source field which has been mapped to the rule.

Hope this helps.

Regards,

Joe

Edited by: lazarus_joey on Feb 16, 2012 2:11 PM

Former Member
0 Likes

hi Ganesh ,

You can try these :

1. translate v_ods using ' '.

helpful to remove any character other than space too .

2. condense v_ods no-gaps .

helpful to remove space .

Regards,

Jaya

Former Member
0 Likes

you can use condense syntax to remove the leading and trailing spaces...

in the field levell routine you can write the code....

RESULT = XXXX

condense RESULT.

Former Member
0 Likes

It's not required to write a routine for this cases! You can simply enable the ALPHA conversion for your info object settings in RSD1/RSD5. Using this a conversion from an external to an internal format takes place viz. 'SAPSCN ' becomes 'SAPSCN'. Conversion routines ALPHA, NUMCV, and GJAHR check whether data exists in the correct internal format before it is updated. For more details please refer http://goo.gl/Wgtlj

anindya_bose
Active Contributor
0 Likes

HI Ganesh

Try this

Result = <your-field>.

CONDENSE RESULT NO-GAPS.

NO-GAPS will remove any space even withing words. Like Anindya Bose will be AnindyaBose.

If you do not want that, use just CONDENSE RESULT.

you can also use Formula , L_TRIM and R_TRIM is there for this purpose

Regards

Anindya