cancel
Showing results for 
Search instead for 
Did you mean: 

Sign '-' Left Alignment in Script

Former Member
0 Kudos

Dera All,

I have field REGUD-WRBTR which is Type CURR in my Print Program and Form.

I want to Display the value as -96 but I am getting value as 96-.

I have tried &REGUD-WRBTR(15) (<)& , Not working.

Used SET SIGN LEFT Command ,Not working.

It's an issue with CURR field , Please suggest how to resole this issue. Find below my Code for reference.

IF WA_REGUP-SHKZG = 'S'.

WA_REGUP-WRBTR = WA_REGUP-WRBTR * '-1'.

MOVE: WA_REGUP-WRBTR TO REGUD-WRBTR.

ELSE.

MOVE: WA_REGUP-WRBTR TO REGUD-WRBTR.

ENDIF.

Regards,

Vikas Badhan

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
0 Kudos

about the initial question, < is ignored if the domain behind REGUD-WRBTR has sign option disabled (SE11, domain).

To combine several formatting options, just concatenate them:

&REGUD-WRBTR(15<)&

Last thing, be careful with number of decimals of &AMOUNT& according to the currency: do a test with a currency which has a number of decimals different from 2.

antony_paul2
Active Participant
0 Kudos

I dont think this approach will ever work, since you are playing around with a character field here. As per my understanding when you CONCATENATE '-' to a character field I dont think it will be considered as a sign. So formating options to handle signs will never work in this scenario.

What you can try here is in the subroutine pool after concatenation you can do a SHIFT LEFT, but then it can't be right aligned with

decimal places anymore.

What I still suggest here is to keep working on a currency field, instead of using a character field and doing a concatenation.

Make regup-wrbtr and negative field by either multiplying it with a -1 or minus it from zero ( regup-wrbtr = 0 - regup-wrbtr )

in your subroutine pool. and assign it back to regup-wrbtr. Then you can use regup-wrbtr(<).

Sandra_Rossi
Active Contributor
0 Kudos

> I dont think this approach will ever work, since you are playing around with a character field here. As per my understanding when you CONCATENATE '-' to a character field I dont think it will be considered as a sign. So formating options to handle signs will never work in this scenario.

I guess Vikas didn't use any formatting option for the character field &AMOUNT&, so it should work. In fact, I made a test, and there are 2 issues when executing the code: the numeric fields are passed right aligned (as you passed &REGUD-WRBTR& without formatting option) so assigning it to a 15 characters field will truncate the value (so remove left spaces before the assignment), and you return IT_OUTPUT without mentioning the parameter name! Here are the changes Vikas has to do:


FORM PUT_MINUS_SIGN TABLES IT_INPUT STRUCTURE ITCSY
IT_OUTPUT STRUCTURE ITCSY.

DATA LV_WRBTR(15) TYPE C.
READ TABLE IT_INPUT INDEX 1.
CHECK SY-SUBRC EQ 0.

LV_WRBTR = IT_INPUT-VALUE.

CONDENSE LV_WRBTR.            "<<<<<<<< ADD
CONCATENATE '-' LV_WRBTR INTO LV_WRBTR.
*CONDENSE LV_WRBTR.           "<<<<<<<< delete
READ TABLE IT_OUTPUT INDEX 1. "<<<<<<<< ADD
CHECK SY-SUBRC EQ 0.          "<<<<<<<< ADD
IT_OUTPUT-VALUE = LV_WRBTR.

MODIFY IT_OUTPUT INDEX 1.

ENDFORM.

> What I still suggest here is to keep working on a currency field, instead of using a character field and doing a concatenation.

I agree.

> Make regup-wrbtr and negative field by either multiplying it with a -1 or minus it from zero ( regup-wrbtr = 0 - regup-wrbtr ) in your subroutine pool. and assign it back to regup-wrbtr. Then you can use regup-wrbtr(<).

As REGUP-WRBTR refers to an unsigned number, regup-wrbtr(<) won't display the sign (as regup-wrbtr alone won't display the sign either). Instead, refer to REGUD-WRBTR (with or without formatting options, it's not the problem) which refers to a signed number (as you can see in the domain).

Edited by: Sandra Rossi on Feb 22, 2010 11:22 AM (CORRECTIONS ADDED)

Former Member
0 Kudos

Thanks Sandra/Antony,

It realy helped, problem solved.

Vikas.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

In your pring program, use below command to shift '-' to left.

SHIFT v_peramt1 UP TO '-' LEFT CIRCULAR.

It worked in my case.

Hope it helps.

Thanks,

Archana

antony_paul2
Active Participant
0 Kudos

s

Edited by: Antony Paul on Feb 20, 2010 11:13 AM

antony_paul2
Active Participant
0 Kudos
&REGUD-WRBTR(15)(<)&

This may not work

but I guess the below should work

&REGUD-WRBTR(<)&

Former Member
0 Kudos

Hi Antony,

I have appied the logic below, I have called a subroutine from script to insert the '-' infront of the value. Somehow getting error when activating the Script, please see the code am i missing something in this, pls revert.

/: IF WA_REGUP-SHKZG = u2018Su2019.

/: PERFORM PUT_MINUS_SIGN IN PROGRAM ZTEST

/: USING REGUD-WRBTR

/: CHANGING &AMOUNT&

/: ENDPERFORM

/ &REGUP-BLDAT& &REGUP-XBLNR(16)& &AMOUNT&

/: ELSE

/ &REGUP-BLDAT& &REGUP-XBLNR(16)& &REGUD-WRBTR(15)&

/: ENDIF

In ZTEST program

FORM PUT_MINUS_SIGN TABLES IT_INPUT STRUCTURE ITCSY

IT_OUTPUT STRUCTURE ITCSY.

DATA LV_WRBTR(15) TYPE C.

READ TABLE IT_INPUT INDEX 1.

CHECK SY-SUBRC EQ 0.

LV_WRBTR = IT_INPUT-VALUE.

CONCATENATE '-' LV_WRBTR INTO LV_WRBTR.

CONDENSE LV_WRBTR.

IT_OUTPUT-VALUE = LV_WRBTR.

MODIFY IT_OUTPUT INDEX 1.

ENDFORM.

Sandra_Rossi
Active Contributor
0 Kudos

could you tell us what error you have?

/: IF WA_REGUP-SHKZG = u2018Su2019.

be careful with quotes (I'm not sure how you typed them), use &WA_REGUP-SHKZG&, and remove the final point.

For other variables VAR, always write them &VAR&