Runtime Error CONVT_NO_NUMBER in program SAPLMEPO (ME21n) - abap

When I'm creating a purchase order that have 10 items (or above), a run time error occurred. Below is the error message.
Category: ABAP Programming Error
Runtime Errors: CONVT_NO_NUMBER
ABAP Program: SAPLMEPO
Include MM06EF0B_BUCHEN
Application Component MM-PUR
An exception occurred that is explained in detail below.
This exception cannot be caught in the context of the current statement. The reason for the exception is: An attempt was made to interpret value "*" as a number. As this value contravenes the rules for displaying numbers correctly, this was not possible.
Below is the code where an exception occurred:
DATA indx.
indx = 1.
* Need to merge KNT and XEKKN
* algorithm is: if knt is old, use knt. Else use the equivalent from xekkn
LOOP AT knt.
IF knt-updkz EQ oldpos.
MOVE-CORRESPONDING knt TO lt_ekkn.
ELSE.
READ TABLE xekkn INDEX indx.
MOVE-CORRESPONDING xekkn to lt_ekkn.
indx = indx + 1.
ENDIF.
APPEND lt_ekkn.
ENDLOOP. "v 2068862
It seems that the data type of indx (char 1), but when PO item index = 9, then index = 10 (actual value is * in debug mode ), so exception is happened.
How should I solve this problem?
I also post this issue here: https://scn.sap.com/message/16146617

You are right in assuming that indx is a C(1) since you (or the author of the code) did not specify a type. Changing the line to
DATA indx TYPE i.
should solve the issue.

Related

Why FF_5 is not posting EBS records to subledgers?

I'm trying to post document through tcode FF_5 (electronic bank statements) as SWIFT MT940 - international format, with immediate posting parameter. Bank Accounting Posting works fine, but Subledger posting doesn't work correctly.
After debugging I found information that document is being posted by FM: 'POSTING_INTERFACE_DOCUMENT'. Inside return table - t_bapiret2 I'm getting message "Batch Input for screen SAPLFCPD 0100 does not exist" (Type: S, ID: 00, NR: 344). When I'm trying to post this without background processing I have to insert name of customer into field BSEC-NAME1 of this screen and it posts fine.
I want to automize this process. How should I pass data to ftpost[] or bdcdata[] tables to inject information about Customer Name? I tried to do it in various ways in debugging mode but none of them worked for me.
Sample BDCDATA[] record that I created:
ft-program = 'SAPLFCPD'.
ft-dynpro = '0100'.
ft-dynbegin = 'X'.
APPEND ft.
CLEAR ft.
ft-fname = 'BSEC-NAME1'.
ft-fval = 'TEST'.
APPEND ft.
EDIT:
Sample bank statement:
:20:MT940
:25:/PL22112110212000180204832110
:28C:56
:60F:C220525PLN89107,30
:61:2205250525D269,98N152NONREF//6450501100324535
152 0
:86:020~00152
~20ZAM.PL111111111, FVKOR/0022
~2111/2205/2401120
~22˙
~23˙
~24˙
~25˙
~3010202964
~310000620200678839
~32CUSTOMER NAME
~33˙
~38PL23102029640000620200678839
~60˙
~63˙
:62F:C220525PLN88837,32
:64:C220525PLN88837,32
-
This is one-time Client, he has no master data information that's why I want to inject it.
I would really appreciate any help.
I added some code to process it as BDC, right now entries are available in SM35.
Code looks like this:
ENHANCEMENT 1 ES_BDC_FEBAN. "active version
data lv_session TYPE APQI-GROUPID.
lv_session = |{ SY-DATUM }{ SY-TIMLO(4) }|.
DATA: lv_name1 LIKE bsec-name1.
GET PARAMETER ID 'FEBAN_NAME1' FIELD lv_name1.
IF lv_name1 IS NOT INITIAL.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = SY-MANDT " Client
group = LV_SESSION " Session name
keep = 'X' " Indicator to keep processed sessions
user = SY-UNAME " Batch input user
EXCEPTIONS
client_invalid = 1 " Client is invalid
destination_invalid = 2 " Target system is invalid/no longer relevant
group_invalid = 3 " Batch input session name is invalid
group_is_locked = 4 " Batch input session is protected elsewhere
holddate_invalid = 5 " Lock date is invalid
internal_error = 6 " Internal error of batch input (see SYSLOG)
queue_error = 7 " Error reading/writing the queue (see SYSLOG)
running = 8 " Session is already being processed
system_lock_error = 9 " System error when protecting BI session
user_invalid = 10 " BI user is not valid
others = 11
.
IF SY-SUBRC <> 0.
ENDIF.
MODE = 'Q'.
clear: FUNCT, SGFUNCT.
* funct = 'B'.
* SGFUNCT = 'B'.
ft-program = 'SAPLFCPD'.
ft-dynpro = '0100'.
ft-dynbegin = 'X'.
APPEND ft TO ft[].
CLEAR: ft-program, ft-dynpro, ft-dynbegin.
ft-fnam = 'BSEC-NAME1'.
ft-fval = lv_name1.
APPEND ft TO ft[].
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
TABLES
dynprotab = ft.
call function 'BDC_CLOSE_GROUP' .
COMMIT WORK AND WAIT.
SUBMIT RSBDCSUB EXPORTING LIST TO MEMORY
WITH mappe EQ lv_session
WITH von EQ sy-datum
WITH bis EQ sy-datum
WITH z_verarb EQ 'X'
WITH fehler EQ ''
WITH logall EQ 'X'
AND RETURN.
ENDIF.
ENDENHANCEMENT.
Variables entries:
Tcode = 'FB01'
FT[]:
<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml"><asx:values><_--5CTYPE_--3D_--25_T00004S00000371O0000147040><item><PROGRAM>SAPMF05A</PROGRAM><DYNPRO>0100</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_CURSOR</FNAM><FVAL>RF05A-NEWKO</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-BLDAT</FNAM><FVAL>25.05.2022</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-BLART</FNAM><FVAL>WB</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-BUKRS</FNAM><FVAL>1700</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-BUDAT</FNAM><FVAL>25.05.2022</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-WAERS</FNAM><FVAL>PLN</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-XBLNR</FNAM><FVAL>PBE01PL41022056</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BKPF-BKTXT</FNAM><FVAL>0000375800001</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>RF05A-NEWBS</FNAM><FVAL>40</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>RF05A-NEWKO</FNAM><FVAL>1232000000</FVAL></item><item><PROGRAM>SAPMF05A</PROGRAM><DYNPRO>0300</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-WRBTR</FNAM><FVAL>269,98</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-VALUT</FNAM><FVAL>25.05.2022</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-ZUONR</FNAM><FVAL>0000375800001PLN</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-SGTXT</FNAM><FVAL>NONREF 020152 ZAM.PL146751217, FVKOR/002211/2205/2</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_CURSOR</FNAM><FVAL>RF05A-NEWKO</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>RF05A-NEWBS</FNAM><FVAL>50</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>RF05A-NEWKO</FNAM><FVAL>1430101010</FVAL></item><item><PROGRAM>SAPLKACB</PROGRAM><DYNPRO>0002</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_OKCODE</FNAM><FVAL>/00</FVAL></item><item><PROGRAM>SAPMF05A</PROGRAM><DYNPRO>0300</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-WRBTR</FNAM><FVAL>269,98</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-VALUT</FNAM><FVAL>25.05.2022</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-ZUONR</FNAM><FVAL>PL1467512</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEG-SGTXT</FNAM><FVAL>NONREF 020152 ZAM.PL111111111, FVKOR/002211/2205/2</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_CURSOR</FNAM><FVAL>RF05A-NEWKO</FVAL></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_OKCODE</FNAM><FVAL>/11</FVAL></item><item><PROGRAM>SAPLKACB</PROGRAM><DYNPRO>0002</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BDC_OKCODE</FNAM><FVAL>/00</FVAL></item><item><PROGRAM>SAPLFCPD</PROGRAM><DYNPRO>0100</DYNPRO><DYNBEGIN>X</DYNBEGIN><FNAM/><FVAL/></item><item><PROGRAM/><DYNPRO>0000</DYNPRO><DYNBEGIN/><FNAM>BSEC-NAME1</FNAM><FVAL>CUSTOMER NAME</FVAL></item></_--5CTYPE_--3D_--25_T00004S00000371O0000147040></asx:values></asx:abap>
Data might looks slightly differently from debugger and bank statement.
There are 2 entries in SM35, first is processed correctly, but 2nd one has log entries like this:
Can somebody help me please?
Most likely you are confusing working principles of FEBAN and FF_5.
In SM35 you will see BI sessions created by FF_5. You need to process them to post real postings.
Also I recommend to retry the failed postings via FEBP transaction, which is called by FF_5 under the hood. It does almost the same as FF_5, and uses FF_5 data, but has the ability to repost the failed records.
The one interesting parameter FEBP has is Bk Pstg Only "Only post to G/L", which may be setting silently by FF_5 which may prevent you to post to subledgers. Though I can't confirm this, it's only assumption.
P.S. Also I recommend to never ever change automatically generated batch sessions like you do, not SAPLFCPD nor any others.
Problem solved. I passed records in ft[] in wrong order.
Very usefull thing is using tcode SHDB as simulation how records should be passed. At my case FT[] table should contain
SAPMF05A scr. 0100
[... required fields ...]
SAPLFCPD scr. 0100
BSEC-NAME1 <-- Injected missing field
SAPMF05A scr. 0300
[... required fields ...]
SAPMF05A SCR. 0301
[... required fields ... -> SAVE]
Topic can be closed. Thank you.

make SQL query fail on condition

For XYZ reason I need a query to explicitly fail (return error code to connection) if some condition is met (on Snowflake).
Can someone recommend an approach?
Some illustration in pseudo-code:
IF 0= ( SELECT COUNT(*) FROM XYZ) THEN FAIL
I like Simeon's approach, but you may want a custom error message if this is running in a long script. Throwing an error in a JavaScript UDF will allow custom (if untidy) error messages:
create or replace function RAISE_ERROR(MESSAGE string)
returns string
language javascript
as
$$
throw "-->" + MESSAGE + "<--";
$$;
select
case (select count(*) from XYZ)
when 0 then raise_error('My custom error.')
else 'There are rows in the table'
end
;
If there are no rows in XYZ, it will generate an error message that reads:
JavaScript execution error: Uncaught --> My custom error <--. in RAISE_ERROR at '
throw MESSAGE;' position 4 stackstrace: RAISE_ERROR line: 2
It's not the tidiest of error messages, but it will allow you to embed a custom error message if you need help identifying the error. The arrows should help direct people to the real error message thrown in the stack.
SELECT IFF(true, 1::number, (1/0)::number);
then:
IFF(TRUE, 1::NUMBER, (1/0)::NUMBER)
1
where-as
SELECT IFF(false, 1::number, (1/0)::number);
gives:
Division by zero

Clone a program which uses a logical database, programmatically

I have a report, let's call it REPORT_A, and I'd like to clone it to REPORT_B, execute REPORT_B, and then come back.
I'm doing the following:
DATA: lv_report_name TYPE c LENGTH 30 VALUE `DEMO_LIST_OUTPUT`,
lv_new_report_name TYPE c LENGTH 30 VALUE `ZZ_DEMO_LIST_OUTPUT`,
lt_report_code TYPE abaptxt255_tab,
lv_message TYPE abaptxt255,
lv_line TYPE i,
lv_word TYPE abaptxt255.
READ REPORT lv_report_name INTO lt_report_code.
SYNTAX-CHECK FOR lt_report_code
MESSAGE lv_message
LINE lv_line
WORD lv_word.
IF sy-subrc = 0.
INSERT REPORT lv_new_report_name FROM lt_report_code STATE 'A'.
GENERATE REPORT lv_new_report_name.
SUBMIT (lv_new_report_name) VIA SELECTION-SCREEN AND RETURN.
ENDIF.
The syntax-check statement is returning sy-subrc = 4, and lv_message contains:
PERNR is not defined for the current logical database
This is the issue -> REPORT_A uses PNP logical database and has a get pernrstatement, so it fails the syntax-check.
Detail: REPORT_A is working just fine, tables pernr is declared in it. If I run it alone in SE38, it executes perfectly.
But, due to this weird error, I am always failing to generate REPORT_B.
Even if I skip the IF condition, it will then DUMP in the submit line, pointing a syntax error referring to the same error, "pernr is not defined for the current logical database".
Is there a way around it?
Can I call get pernr dynamically, so it doesn't fail the syntax check?
First of all, be careful, INSERT REPORT and GENERATE REPORT are statements for internal use (reserved to SAP).
If you still want to use the internal statements, see the rest of my answer.
Otherwise the workaround is to use GENERATE SUBROUTINE POOL. But it won't work for a logical database. If you copy a standard program maybe it's not a good idea of copying it (no note assistant to help you in case of patch/upgrade), so the classic workarounds are to add implicit enhancement options, or use eventual user exits proposed by SAP in this particular program (if any). There might be other options, but it depends on your exact goal, which you didn't share (yet).
The statement INSERT REPORT creates a source code module with a program entry (in table TRDIR) which by default corresponds to an Executable program (A.K.A. "report"), and so can be executed with SUBMIT.
But in your case, the program you want to generate is a program using a Logical Database, so you must assign the program attribute Logical database (TRDIR-LDBNAME).
The program attributes are to be passed via the words DIRECTORY ENTRY in the following statements:
SYNTAX-CHECK ... DIRECTORY ENTRY ls_trdir
INSERT REPORT ... DIRECTORY ENTRY ls_trdir
An easy solution for copying an existing program is to read its program attributes from the table TRDIR, change the name of the program (TRDIR-NAME) that you are creating, and pass them after the words DIRECTORY ENTRY.
Additional comments:
COMMIT WORK should be placed after GENERATE REPORT as explained in the documentation.
SY-SUBRC should be checked after INSERT REPORT and GENERATE REPORT.
Consequently, the following code will work:
DATA: lv_report_name TYPE c LENGTH 30 VALUE `DEMO_LIST_OUTPUT`,
lv_new_report_name TYPE c LENGTH 30 VALUE `ZZ_DEMO_LIST_OUTPUT`,
lt_report_code TYPE abaptxt255_tab,
lv_message TYPE abaptxt255,
lv_line TYPE i,
lv_word TYPE abaptxt255,
ls_trdir TYPE trdir.
READ REPORT lv_report_name INTO lt_report_code.
SELECT SINGLE * FROM trdir INTO ls_trdir WHERE name = lv_report_name.
ls_trdir-name = lv_new_report_name.
SYNTAX-CHECK FOR lt_report_code
MESSAGE lv_message
LINE lv_line
WORD lv_word
DIRECTORY ENTRY ls_trdir.
IF sy-subrc = 0.
INSERT REPORT lv_new_report_name FROM lt_report_code STATE 'A' DIRECTORY ENTRY ls_trdir.
IF sy-subrc = 0.
GENERATE REPORT lv_new_report_name.
IF sy-subrc = 0.
COMMIT WORK.
SUBMIT (lv_new_report_name) VIA SELECTION-SCREEN AND RETURN.
ELSE.
* Handle the error + rollback
ENDIF.
ELSE.
* Handle the error + rollback
ENDIF.
ELSE.
* Handle the error
ENDIF.

Can not catch error in merge statement

Hi I have problem to catch the error in merge statement.
The merge statement will get the following error when run in SQL Plus:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
When I execute the statement with ExecuteNonQuery in Vb.net will not get any exception.
Is there any way to catch that error in Vb.net without using log errors in merge statement?
EDIT:
Try
Dim count as Interger=0
Dim cmd As New OleDb.OleDbCommand(strSQL)
count = cmd .ExecuteNonQuery()
Catch ex as Exception
... Respond ...
End Try
Sample Merge Statement with error:
MERGE INTO TABLE_A a USING
(
SELECT ID,SUM(AMOUNT) AMOUNT
FROM TABLE_B b
GROUP BY ID
) b
ON ( b.ID=a.ID )
WHEN MATCHED THEN
UPDATE SET a.AMOUNT=a.AMOUNT+b.AMOUNT
WHEN NOT MATCHED THEN
INSERT (ID, DT, AMOUNT) VALUES (b.ID, 0, b.AMOUNT);
The SQL Plus will get error at the insert but Vb.net can not catch.
The data type for field DT is DATE.
EDIT 3:
My bad - in that case, I think you'll have to subscribe to oleDbConnection.InfoMessage event and check for applicable SQL-00932 messages after the MERGE command. I don't see any equivalent property to FireInfoMessageEventOnUserErrors in OLE-DB (which, again, seems totally backwards...).
EDIT 2:
It appears there's a default threshold that will cause vb.net to ignore certain SQL exceptions (can't fathom the rationale behind such a decision). Regardless, I think if you do the following, you should see the exception raised.
cmd.FireInfoMessageEventOnUserErrors = true;
End EDIT2
EDIT: I just read the problem a bit closer. If the vb.net execution is not throwing any exception at all, that would indicate that you're not running the exact same statement in both. My initial guess is that you're passing a date parameter that is passing SQL Plus string variable incorrectly as 01/01/2015 (which is 1 divided by 1 divided by 2015) and vb.net variable correctly as '01/01/2015' (that is, as a string with quotation marks).
End EDIT
I have no idea what you mean by "using log errors in merge statement", but it sounds like you just need the syntax for using the vb.net try-catch syntax to catch and act on Oracle errors.
From here: http://www.tek-tips.com/viewthread.cfm?qid=467119
Pertinent code snippet:
Try
... Sql here ...
Catch ex as OleDbException
... Respond to error here ...
End Try

Unhandled exception when using VB arithmetic operators

I have a function that loops through a list of servers, and then for each carries out a number of functions.
At the beginning each iteration, I need to calculate which 'step' the process is currently at (so that a progress bar can be updated correctly), but this line is causing an error -
Me.CurrentStepLoop = ((Me.CurrentServerLoop - 1) * Me.ServerSteps) + 1
All three of the referenced properties are integers, and the values are quite low (I.e CurrentServerLoop has a maximum of 6 and ServerSteps has a maximum of 20, soCurrentStepLoop can be no more that 101 from this equation.
Here is the error that I am getting -
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
I find it particularly odd that I have the line in question within a Try...Catch, yet the error is not handled by my code and instead I see generic Visual Exchange error. The line is not actually highlighted, but I know it is that as if I comment it out the error does not occur
Can anybody shed some light on why this may be happening? Thanks.
Here is the snippit that I believe is causing the issue, as well as a link to the full code -
For Each CurrentServer In Me.Servers
If bw.CancellationPending = True Then
e.Cancel = True
Exit For
Else
Try
Me.CurrentStepLoop = ((Me.CurrentServerLoop - 1) * Me.ServerSteps) + 1
Catch Ex As Exception
Dim ErrorForm As New formError(Ex)
e.Cancel = True
Exit For
End Try
MappingResult = Me.DoMapDrives(CurrentServer)
If Not MappingResult Then bw.CancelAsync() : Exit For
{...Other actions here...}
CurrentServerLoop += 1
End If
Next
I have found the error and why it occurred.
In the method SetSteps() I calculate Me.StepSize, but I was doing so incorrectly. Changing this -
Me.StepSize = Me.proProgress.Maximum / Me.ServerSteps
To this solved the problem -
Me.StepSize = Me.proProgress.Maximum / Me.TotalSteps
The issue was that the Progress bar was being set passed it's maximum, which caused the error. Thanks.