cancel
Showing results for 
Search instead for 
Did you mean: 

Extract Sales text from MM03

Former Member
0 Kudos

Hi All,

I am trying to extract sale text from MM03 for a few items.

I am able to extract it; but the problem is that if the sales text is in different lines that is it has more than 1 line one below the other as content, I am getting everything in one line in excel and not as in SAP.

Can someone help

Sub salestext()

Dim t As String

Set SapGuiAuto = GetObject("SAPGUI")

Set App = SapGuiAuto.GetScriptingEngine

Set Connection = App.Children(0)

Set session = Connection.Children(0)

For i = 2 To Sheets("Data").Range("A1048576").End(xlUp).Row

session.findById("wnd[0]").maximize session.findById("wnd[0]/tbar[0]/okcd").Text = "mm03"

session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = Sheets("Data").Range("A" & i)

session.findById("wnd[0]").sendVKey 0 session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").Text = "3601"

session.findById("wnd[1]/tbar[0]/btn[0]").press On Error GoTo skip session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP08").Select

session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").Text = "3601"

session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").Text = "00"

session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").SetFocus

session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").caretPosition = 2

session.findById("wnd[1]/tbar[0]/btn[0]").press

t = session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP08/ssubTABFRA1:SAPLMGMM:2010/subSUB2:SAPLMGD1:2121/cntlLONGTEXT_VERTRIEBS/shellcont/shell").Text

session.findById("wnd[0]/tbar[0]/btn[3]").press

Sheets("Data").Cells(i, 3) = t

skip:

session.findById("wnd[0]/tbar[0]/btn[3]").press

Next

End Sub .

Accepted Solutions (1)

Accepted Solutions (1)

holger_khn
Contributor
0 Kudos

Hello.

I have created an Excel macro which call RFC-enabled functionmodule RFC_READ_TEXT.

I would suggest to use same method as all other Options have not solved my requirements.

Create an Excel worksheet as in attached Picture.

Insert attached Textfile Content in Excel VBA module.

Add two Buttons on worksheet and assign macro "RFC_Read_Table" to extract button and macro "Clear_Sheet_Data" to button for clear Content on worksheet.

Hope this help to achieve your requirements.

Best regards,

Holger


Former Member
0 Kudos

Hi Holger Kohn,

First of all I apologize for replying very late.

I tried your code.

But I am getting No sales text exist in column D

and Return message as Text 000000000000000001C36000 ID 0001 language EN not found

for material 000001 and similarly no values for other materials as well.

Can you teach me( or get me some documents/site where I can learn RFC technique) RFC.

I am totally new to it and would like to learn it fully.

Anyways thanks a lot for the valuable code (at least I could get a small idea of RFC).

I am sure It might be just a few tweaks in the code and it will be all OK.

Regards

Krishna Kumar

holger_khn
Contributor
0 Kudos

Hello.

I suggest to check Longtext Header if your Setup is similar to my Systems:

In MM02 on Sales Text tab call Longtext Editor:

Then goto 'Header':

Check Text Name with Returnmessage from Excel macro-enabled template.

Below the logic from macro and screenshot of Sales Text Header -> I guess this Need no further explaination. If Text Name from Returnmessage is different to below from Text Header you Need to adjust macro logic that it will fit to your System requirements.

tblText_Lines(1, "TDOBJECT") = "MVKE"

tblText_Lines(1, "TDSPRAS") = ThisWorkbook.Sheets("Data").Cells(iRow, 3).Value

tblText_Lines(1, "TDNAME") = strMATNR & ThisWorkbook.Sheets("Data").Cells(iRow, 2).Value & "00"

tblText_Lines(1, "TDID") = "0001"

Hope this helps.

Best regards

Holger

Former Member
0 Kudos

Hi Holger Kohn,

Again sorry to reply very late.

I do not have access to MM02.

I will try in some1s system who has access.

I will get back soon as soon as I try it out.

Regards

Krishna Kumar

holger_khn
Contributor
0 Kudos

Hello.

Same header Data can be Check using Transaktion MM03. No Need for MM02.

Former Member
0 Kudos

Holger,

Do I require something like RFC Connection (I do not know the exact name) to be enabled.

I felt like asking this as I saw some youtube videos regarding RFC and it showed like enabling something in SM37 or so.

I am very new to SAP scripting and have not seen any code having something related to RFC until now.

Sorry, if I spoiled your time.

Regards

Krishna Kumar

holger_khn
Contributor
0 Kudos

Hello.

As you have get an returnmessage back everything is ok with RFC authorization aso.

In case of missing technical or role authorization you will get an runtime error. As this is not the case here it should be fine.

Please make a screenshot of Editor Header for Sales longtext object.

I strongly believe it has something to do with the Text Name creation in macro code.

Thanks.

Br, Holger

Former Member
0 Kudos

Hi Holger,

Here is it

holger_khn
Contributor
0 Kudos

WWhen you Test material VCC57 in Excel sehet you got exactly he Same textname in returnmessage als error?

Former Member
0 Kudos

Hi Holger,

Finally it is working.

Thanks for following up everytime.

Regards

Krishna Kumar

holger_khn
Contributor
0 Kudos

hello. Great To hear that everything working fine now.

Answers (0)