2014 Feb 19 9:25 AM
Hi all,
I am making a module pool program in which I have to capture the gross weight and tare weight.
I am importing the weight from the weigh bridge and the Importing medium is .net.
I have made an internal table with two fields.
cl_gui_frontend_services=>clipboard_import(
IMPORTING
data = it_weight
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
).
LOOP AT it_weight INTO wa_weight.
ST_REF-GROSS_WEIGHT = wa_weight-in.
ST_REF-TRUCK_WEIGHT = wa_weight-out.
ENDLOOP.
Both the fields are of type P.
But I am getting this error.
Calculation Field is too Small.
2014 Feb 19 11:48 AM
Issue is partially solved. I replaced decimal to numeric. Error is gone but the system fetches only 1 character of 100(for instance if i copy this value to clipboard).
Any solution????????
2014 Feb 19 9:35 AM
Hi,
when you define a variable type P you could specify the size. Witch size did you define, what it is the value SAP try to put in it ?
regards
Fred
2014 Feb 19 9:50 AM
Hi Frederic,
I have define the variable type P decimals 5.
Still it is giving error.
I cant declare the variable length in Module pool screen so in that screen i have maintained the field as type decimal.
2014 Feb 19 9:54 AM
You define the dynpro ? you could make a reference to the dictionary and you could define the size of the field with the dictionary
no ?
Fred
2014 Feb 19 9:56 AM
hi Yash
the length of GROSS_WEIGHT or TRUCK_WEIGHT can`t small than wa_weight-in or out.
i think the module pool screen can define the length.
regards,
Archer
2014 Feb 19 10:00 AM
you can choose D16D as type. only large than wa_weight-in or out.
2014 Feb 19 10:08 AM
Hi Dengyong.
I didnt get you.
What is D16D.
Actaully I am getting the values in clipboard but it is some junk value.
E.g if i copy 6000 3000 in notepad and when my code gets executed the system show some 36600000.00000 333000000.00000 value.
2014 Feb 19 11:36 AM
hi,
you can try change the type of the field 'IN' and 'OUT' to c, length 4.
then
LOOP AT it_weight INTO wa_weight.
MOVE wa_weight-in to ST_REF-GROSS_WEIGHT.
MOVE wa_weight-out TO ST_REF-TRUCK_WEIGHT.
ENDLOOP.
but previous that, you must know the length of GROSS_WEIGHT and RUCK_WEIGHT. you can debug to check it.
regards,
Archer
2014 Feb 19 10:17 AM
does the dynpro have anything to do with this? Is it an error message on the dynpro, or a dump, generated from the method clipboard_import( )?
2014 Feb 19 10:23 AM
Dynpro has nothing do with this. But when I capture the weight it is giving runtime error.
2014 Feb 19 10:19 AM
Hi Yash,
As you told in module pool screen you defined type as Decimal better to define it as UNIT because Quantity all ways need to refer to type QUAN. And in program you define type as p length 13 decimals 3.
For more refenece abt type you can see domain MENG13.
Regards,
Vineesh.
2014 Feb 19 10:21 AM
Thank You Vineesh.
But I am capturing weight in this module pool.
2014 Feb 19 10:28 AM
Hi,
what is the content of wa_weight-in and wa_weight-out. Maybe there is a conversion issue with decimal points or something like that ...
Regards,
Klaus
2014 Feb 19 10:31 AM
2014 Feb 19 10:38 AM
2014 Feb 19 10:45 AM
LOOP AT it_weight INTO wa_weight.
ST_REF-GROSS_WEIGHT = wa_weight-in.
ST_REF-TRUCK_WEIGHT = wa_weight-out.
ENDLOOP.
when I get some junk value in the itab (IT_WEIGHT).
When the value which i am getting is transfferd to the ST_RED-GROSS_WEIGHT
the junk value also have 6 decimal place and in my declaration it is also having 6 decimal place.
2014 Feb 19 10:57 AM
By default type P has 8 Byte which is 15 digits. If you have DECIMALS 6 then you will have 9 digits before decimal point and 6 digits after it.
But you can increase ST_REF-GROSS_WEIGHT to ST_REF-GROSS_WEIGHT(16), then you have place for 31 digits with 25 digits before and 6 after decimal poitn.
Make sure, that you hve no unicode conversion issue (every second Byte will contain '00'.
Regards,
Klaus
2014 Feb 19 11:34 AM
Klaus the problem is as below. :
the value which i copy for clipboard import is different and the value which is imported is different.
the value which I have copied is a 4 digit value. but system returns some other value with 6 decimal plac and 10 before decimal.
2014 Feb 19 11:44 AM
Hi,
then you need
ST_REF-GROSS_WEIGHT(9) type P decimals 6
for that. It will have 17 digits with 11 before and 6 after the decimal point.
Regards,
Klaus
2014 Feb 19 11:09 AM
I have define the variable type P decimals 5.
So implicitly a length 8 (P) so maximum is 9999999999.99999, should be enough for a truck. If not use a bigger length.
Else I could only suppose the clipboard contains some thousand separator(s) and/or an unrecognized decimal separator, you could try to remove unwanted character and condense the string before the compute.
Also how did you define the internal table it_weight ?
Regards,
Raymond
2014 Feb 19 11:39 AM
Hi Yash,
I have also worked in the Iron Ore and Mining Industry as an ABAPer for more than 1 year. I had exactly the same requirement. I used WS_EXECUTE and CLPB_IMPORT function modules to execute the 3rd party software.
Anyway in the above code, there are 2 fields, for which field it is showing too small?
Regards
Purnand
2014 Feb 19 11:48 AM
Issue is partially solved. I replaced decimal to numeric. Error is gone but the system fetches only 1 character of 100(for instance if i copy this value to clipboard).
Any solution????????
2014 Feb 19 11:55 AM
Hi,
if you define a field of type n default length is 1.
DATA: myfield type n.
has length 1.
DATA: myfield(15) type n.
is of length 15,
Regards,
Klaus
2014 Feb 19 12:08 PM
I modified this as you said. Again it fired the same error. 😞
2014 Feb 19 12:13 PM
And you did it for both source and target fields?
ST_REF-GROSS_WEIGHT = wa_weight-in.
ST_REF-TRUCK_WEIGHT = wa_weight-out.
All four fields need the length gt 1.
Regards,
Klaus
2014 Feb 19 12:17 PM
2014 Feb 19 12:29 PM
please try what i said.
i copied a number to clipboard, and use that method to import.
it was worked.
2014 Feb 19 12:54 PM
If you fill and read your clipboard data with ABAP, the solution works fine:
REPORT ztest_clipboard.
TYPES: BEGIN OF x_weight,
min_weight(15) TYPE n,
max_weight(15) TYPE n,
END OF x_weight.
DATA: xv_rc TYPE i.
DATA: xs_weight TYPE x_weight.
DATA: xt_weight TYPE TABLE OF x_weight.
START-OF-SELECTION.
CLEAR xt_weight.
xs_weight-min_weight = 15.
xs_weight-max_weight = 25.
APPEND xs_weight TO xt_weight.
cl_gui_frontend_services=>clipboard_export(
IMPORTING
data = xt_weight
CHANGING
rc = xv_rc
EXCEPTIONS
OTHERS = 0
).
CLEAR xt_weight.
cl_gui_frontend_services=>clipboard_import(
IMPORTING
data = xt_weight
EXCEPTIONS
OTHERS = 0
).
You can try and debug the above code. But how do you fill your clipboard data?
Regards,
Klaus
2014 Feb 19 1:16 PM
Thanks man...
I am getting the data from notepad.. I mean, i simply copy the data from notepad.
2015 Apr 17 7:53 AM
Hi Yash,
Our Client is using "Avery India" WeighBridge
How can I copy weight from its software to clipboard.
They are using some standard software given by AVERY INDIA . Its built in VB I guess.
Thanks in advance