Tuesday, 6 October 2015

VB Documentation tool...

I was asked to ensure that the documentation on a program had pseudo-code in it to describe what was going on in...

I had originally cut and pasted the code (lazy, but consistent with what I'd seen from previous documentation on the same project, and also, I got time issues...) which prompted the user to ask for better explanation of what was going on...

The trick for us ABAPers is the balance between the technical and the functional; we have to describe things in English to the Apps guys, and explain things in ABAP to The Computer, and it's often difficult to do both at the same time in a technical spec:

A way of making this easier is to just make sure that every time you output a field name, you output the description as well (and vice versa, but this is less achievable automatically )

The project I'm on is asking for 10 word documents where this is done.

Rather than doing "replace EKPO with EKPO(PO Line Item)" x ten files x 25 different fields, I thought it more prudent to write some code to do it.

Why get a man to do a machine's job?

Anyway, this is some VBScript that will quickly do all the replacements. The fact that it happens slow enough for the eye to see is really satisfying, as it kind of looks like code from films.

Sub Macro2()
'

Dim findandreplace(1, 25) As String

findandreplace(0, 0) = "VBELN"
findandreplace(1, 0) = "VBELN(Sales Document#)"

findandreplace(0, 1) = "posnr"
findandreplace(1, 1) = "POSNR(Line Item#)"

findandreplace(0, 2) = "kunnr"
findandreplace(1, 2) = "KUNNR(Customer#)"

findandreplace(0, 3) = "vkorg"
findandreplace(1, 3) = "VKORG(Sales Org)"

findandreplace(0, 4) = "vtweg"
findandreplace(1, 4) = "VTWEG(Distribution Channel)"

findandreplace(0, 5) = "vbep"
findandreplace(1, 5) = "VBEP(Schedule Line Data)"

findandreplace(0, 6) = "matnr"
findandreplace(1, 6) = "MATNR(Material)"

findandreplace(0, 7) = "lfstk"
findandreplace(1, 7) = "LFSTK(Delivery status)"

findandreplace(0, 8) = "EDATU"
findandreplace(1, 8) = "EDATU(Schedule line date)"

findandreplace(0, 9) = "EZEIT"
findandreplace(1, 9) = "EZEIT(Arrival time)"

findandreplace(0, 10) = "ABGRU"
findandreplace(1, 10) = "ABGRU(Reason for rejection)"

findandreplace(0, 11) = "PARVW"
findandreplace(1, 11) = "PARVW(Partner Function)"

findandreplace(0, 12) = "WERKS"
findandreplace(1, 12) = "WERKS(Plant)"

findandreplace(0, 13) = "VBAP"
findandreplace(1, 13) = "VBAP(SO Line Item)"

findandreplace(0, 14) = "VBAK"
findandreplace(1, 14) = "VBAK(SO Header)"

findandreplace(0, 15) = "LFSTK"
findandreplace(1, 15) = "LFSTK(Delivery Status)"

findandreplace(0, 16) = "WBSTK"
findandreplace(1, 16) = "WBSTK(Total goods movement status)"

findandreplace(0, 17) = "LIFSP"
findandreplace(1, 17) = "LIFSP(Default delivery block)"

findandreplace(0, 18) = "SPRAS"
findandreplace(1, 18) = "SPRAS(Language)"

findandreplace(0, 19) = "VBUK"
findandreplace(1, 19) = "VBUK(Sales Document Admin Data)"

findandreplace(0, 20) = "KNKK"
findandreplace(1, 20) = "KNKK(Customer Credit)"

findandreplace(0, 21) = "LIKP"
findandreplace(1, 21) = "LIKP(SD Document: Delivery Header Data)"

findandreplace(0, 22) = "bolnr"
findandreplace(1, 22) = "BOLNR(Tare/Registration#)"
                     
findandreplace(0, 23) = "makt"
findandreplace(1, 23) = "MAKT(Material Texts)"

findandreplace(0, 24) = "kkber"
findandreplace(1, 24) = "KKBER(Credit Control Area)"

findandreplace(0, 25) = "LFDAT"
findandreplace(1, 25) = "LFDAT(Delivery Date)"


For j = 1 To 25

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = findandreplace(0, j)
        .Replacement.Text = findandreplace(1, j)
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

Next j



End Sub

No comments:

Post a Comment