Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

FI users often have to enter a series of document line items and then create an offsetting entry that is the total of the line items with the opposite sense so that the document nets to 0. (If the total is a credit, a debit entry must be added and vice versa.) But the user may not have the total at hand and would like to have the final entry determined without having to go to a calculator or a spreadsheet. If you create a document using say FB50, this can be done automatically by entering all the line items with the correct amounts except for the last item. For the last item, the user can enter a “*” in the amount and the program will calculate and populate the total after the user presses enter. If you find yourself being asked to do something similar, the following program should help to guide you along. 

Some Things to Note 

  • The program is not meant as a tutorial on dialogue programming. It assumes that you are already familiar with those concepts (including using table controls). If you are not, you should get some experience with screen programming before trying this.
  • The program is dirty. I have not taken a great deal of effort to add any extras or do any checking that would normally be done. This is another reason not to use this as a model dialogue program.
  • The program consists of one executable program with a screen and a GUI status.
 Getting Started 
  • Create a local program with type “1” (executable).
  • Copy the code below into the program
     
  • Double click on ‘9999’ in the line:    CALL SCREEN 9999.

  • This will take you the screen painter where you can create your screen.
  • I included a number of fields from the data dictionary object BSIS. You don’t need to use all of the ones that I did, but it should match your internal table and you will need at least BSIS-DMBTR and BSIS-SHKZG. They will need to be in a table control called MY_CTL. The screen type is “normal” and the next screen is just 9999.
  • When you copy the fields into the table control, take the default attributes.
  • Copy the following code into the flow logic for the screen.

  • Back in the program, double click on ‘STD’ in the line:  SET PF-STATUS 'STD'.
  • This will take you to the user interface maintenance screen. You will need to create a simple GUI status here that allows you to get out of the screen. You can simply enter ‘CAN’ above the red “X” in the standard toolbar in the “Function keys”. Then click on the red “X” to bring up the function attributes. The Function type should be ‘E’ (exit command). The screen will then recognize the “cancel” button correctly.
  • Save and activate everything.
  • Test – you should be able to enter data in all fields. No real checking will be done now, but the screen should re-populate itself after the enter key is pressed.

 Seeing what’s going on

When you copied the field DMBTR from the data dictionary and kept the default attributes, the “* Entry” attribute was not clicked on. Now, when you execute the program and the screen comes up, enter a numeric value in the “Amount” field and press enter. There should be no problem doing this. Then try entering a non-numeric character (other than “*” or “-“) in the amount. You should find that the screen will not accept the entry at all. Finally, enter “*” in the amount (without the quotes) and press enter. Unlike a normal non-numeric character, you can enter this; however, when you press enter, you should get an error: “Input should be in the form __,___,___,__~.__”.

Now go back to the screen attributes and click on the “* Entry” attribute on the “program” tab of the attributes. Save and generate the screen. Go back and try entering the same data in the amount as you did earlier. You will find that it behaves similarly with a couple of exceptions: if you enter exactly one “*”, you will not get an error and the “*” will not be re-displayed; if you enter a “*” followed by a number, the number will be shifted left by one character so that the “*” again disappears.

This is the first thing you have to realize – clicking on the “* Entry” attribute will allow you to enter a “*” in a numeric field. Note that you can click this on for other fields and maybe you can use this in some way, but for now it is only relevant for this currency field. But what good is entering a “*” in a numeric field? Not much yet – the entry was simply removed. Now we are ready to look at the second important point:

  • Go back to the flow logic for the screen and notice that one line is commented out: *   FIELD bsis-dmbtr MODULE get_balance ON *-INPUT.
  • Remove the leading asterisk (un-comment the line back in).
  • Save and activate the screen

 Now you are ready to do a real test. In the first two lines, enter a debit/credit indicator of “S” (debit) and in the first line an amount of 100 and in the second one an amount of 200. On the third line, enter a “*” in the amount and press enter. If we’ve both done everything correctly, the first two lines will be re-displayed normally, but the third line will have “H” (credit) in the debit/credit indicator and an amount of 300. So the program was able to calculate and populate the amount and sense of an offsetting entry.

Some Further Things to Note 

  • You can enter a “*” in more than one line, but probably don’t want to allow your users to do so. It will just go on calculating totals and they may not be meaningful. It might be best to restrict the “*” to the last line only.
  • The last time I looked, transactions like FB50 allow “*” in more than one line. There are probably reasons for this, but they escape me.
  • Also the last time I looked, transactions like FB50 calculate the total correctly but not the debit credit indicator. So this may be an improvement
  • You are not restricted to calculating totals. I haven’t tried this, but you could probably use “ON *-INPUT” on other types of fields and have different types of special logic.
  • If you press F1 on MODULE, you will see some documentation for ON *-INPUT
  • This program and screen was developed in 4.7. I would expect similar results in different releases, but your results may vary.
10 Comments