cancel
Showing results for 
Search instead for 
Did you mean: 

Adding zero in input field value

Former Member
0 Kudos

Hi,

I have made an app in HWC in SMP 2.3.This app have an input field(Order no.), on the base of this number, it display order list.this is working fine.

I am using Standard Bapi in background for displaying the detail on the base of this number.

This order have length of 12 char, and my order number is 4000020.So i have to add manually 5 zero before this number to make it 12 char

i.e.(000004000020).

So, my concern is that " is it possible that it will convert automatically to 12 char by adding zero".?

Please suggest.

Thanks,

Rohit

Accepted Solutions (0)

Answers (3)

Answers (3)

midhun_vp
Active Contributor
0 Kudos

Is this issue resolved ?

Former Member
0 Kudos

Yes,i get the value and added my required logic.

Thank you.

Rohit

Virinchy
Active Contributor
0 Kudos

You may try any of these two methods

1) throw an alert to user to enter exactly 12 character number instead of wrongly entered value. This can be done in the properties of the edit box(Input box).

2)Add a wrapper to the standard BAPI with a similar  logic of input valuation that happens in standard BAPI

i.e.. user enters  value in mobile device--> value goes to BAPI wrapper (which has input valuation as of standard BAPI and manipulation of inputs happen here) --> manipulated value is sent to -->Standard BAPI and process happens as before.

Former Member
0 Kudos

Thanks Viru.

Customer does not want to wrap the BAPI. We need to consume BAPI directly.

So ,there is any other option?

Adding one more question here,

can we convert input word in CAPITAL.i.e. if user enter matv, it will convert into MATV automatically.

Thanks,

Rohit

Virinchy
Active Contributor
0 Kudos

I am not completely sure if this can be possible with only a standard bapi. with out any enhancements.

May be you can try this with abapers.

Lets wait for other experts opinion.

raymond_giuseppi
Active Contributor
0 Kudos

An Abaper would use the FM associated to ALPHA conversion-exit. But for an external call this is not a solution (even not RFC enabled)

Hopefully SAP provided you some tools in Service BAPIs for General BAPI Functions BapiService.DataConversionInt2Ext1() and BapiService.DataConversionExt2Int1() (Here 4000020 is External format and 000004000020 is Internalformat) It should also convert to upercase fields defined in SAP without lowercase (at domain level)

So you may be required to use more BAPI but no wrapper.

Regards,

Raymond

midhun_vp
Active Contributor
0 Kudos

Yes, you can add zeroes to make it a 12 character number to pass it to the BAPI input or else from BAPI you can add the zeroes before processing, an abaper can do this.

Midhun VP

Former Member
0 Kudos

I am also an ABAPer, as i am consuming BAPI directly in it. So, there is no option, where we add zero.

Thanks.

Rohit

Former Member
0 Kudos

I am also an ABAPer, as i am consuming BAPI and Standard RFC directly in it. So, there is no option, where we add zero.


Thanks.

Rohit

midhun_vp
Active Contributor
0 Kudos

How you are passing the input to the BAPI from app ?

It is easy to add zeroes from BAPI, get the input 4000020, add zeroes to it and give the output.

Midhun VP

Former Member
0 Kudos

I am passing input value to BAPI using Personalization Key.I am giving in input value(4000020) in input field, which is passing to BAPI bu above key.

midhun_vp
Active Contributor
0 Kudos

In that case you can add the zeroes from input field itself and pass it to BAPI right. Pass 000004000020 instead of 4000020 from input field.

Midhun VP

Former Member
0 Kudos

This i already knows.As we have conversion routine in ABAP. is there any way to convert in SMP as in ABAP.Because customer does not want to enter extra zero before number.

can we do some change in custom.js?

Thanks.

Rohit

midhun_vp
Active Contributor
0 Kudos

Alright, you can achieve this in custom.js. Before sending the message value collection you can modify it and send.

You need to first get the data entered in the editbox using the below code:

Add the below code inside your custom.js

// The function customBeforeMenuItemClick you can find inside custom.js

hwc.customBeforeMenuItemClick = function(screen, menuItem) {

if (screen === "Start" && menuItem === "Inventory_detail") // Here you have to give the key of your screen and the button key.

{

var form = document.forms[screen + "Form"];

if (form)

{

cost = form.Enter_Airline_ID.value; // Enter the key of the edit box, cost is a global variable hence it can be accessed anywhere in the custom.js file

// you need to add the zeroes to cost here.

}

if (cost==null || cost == "") //add more fields here for validation.

{

alert("Please enter the mandatory fields");

return false;

}

}

return true;

};

Use the below code to modify the workflow message:

hwc.customBeforeSubmit(screenKey, actionName, workflowMessageToSend) {

if (screenKey == "Start" && (actionName == "Inventory_detail")) {

var myNewValue1 = new MessageValue();

myNewValue1.setKey("keyAppID2");// Your personalization key name

myNewValue1.setValue(Cost);

myNewValue1.setType("TEXT");

var mvc = workflowMessageToSend.getValues();

if( mvc ) {

mvc.add( myNewValue1.getKey(), myNewValue1 );

}

}

return true;

}



Note: Do not map the PK with editbox key in the properties of menuitem used for operation, we are doing it from custom.js

Midhun VP